In this assignment you'll build some predictive regression models with R on a dataset containing inpatient discharges from hospitals in New York.
The version of this data that we'll be using is from a Kaggle dataset. See https://www.kaggle.com/jonasalmeida/2015-deidentified-ny-inpatient-discharge-sparcs. Unfortunately, the column metadata wasn't posted. However, since this is a publicly available dataset, we can visit the source at https://health.data.ny.gov/Health/Hospital-Inpatient-Discharges-SPARCS-De-Identified/82xm-y6g8.
If you scroll down on that page you'll find descriptions of the columns (click the little Show All link to display the entire list).
Most of the fields are self-explanatory. You'll notice that there are several sets of diagnosis and procedure codes. A few definitions are helpful.
The CCS system was developed by the Agency for Healthcare Research and Quality (AHRQ) to provide a classification system better suited to healthcare research. There are CCS diagnosis codes and CCS procedure codes. From their website:
The Clinical Classifications Software (CCS) for ICD-9-CM is a diagnosis and procedure categorization scheme that can be employed in many types of projects analyzing data on diagnoses and procedures. CCS is based on the International Classification of Diseases, 9th Revision, Clinical Modification (ICD-9-CM), a uniform and standardized coding system. The ICD-9-CM's multitude of codes - over 14,000 diagnosis codes and 3,900 procedure codes - are collapsed into a smaller number of clinically meaningful categories that are sometimes more useful for presenting descriptive statistics than are individual ICD-9-CM codes.
As we did in class, you'll be creating an R Markdown document to do the analysis as well as to document the steps you did (and answer some questions I'll throw at you).
You'll notice a few "Hacker Extra" tasks thrown in. These are for those of you who want to go a little above and beyond and attempt some more challenging tasks.
Save this file as a new R Markdown document and name it something that includes your last name in the filename. Save it into the same folder as this file.
Create an R Studio project in the current folder (the one containing this file). You'll notice that there is a folder named data. Inside of it you'll find the data file for this assignment:
The full dataset contains over two million records and is available as a CSV file from Kaggle. I did a little data filtering and cleaning to create a subset to use for this regression assignment. Specifically, I did the following:
APR MDC Code == 4. These are patients having respiratory related diagnoses.chr and I changed them to factors using as.factor.chr because of the leading dollar sign. Now they are numeric.See the data prep script for all the details. You do NOT need to run the data prep script. I'm just including it so you can see a typical data prep script.
#load("./data/ipd_resp.RData")
load('ipd_resp.RData')
#str(ipd_resp)
Just run this chunk to create training and test datasets. This way we'll all be working with the same datasets. Notice that the test set is 30% of the full dataset.
set.seed(1828)
sample_size <- ceiling(0.30 * nrow(ipd_resp))
testrecs <- sample(nrow(ipd_resp),sample_size)
ipd_test <- ipd_resp[testrecs,]
ipd_train <- ipd_resp[-testrecs,] # Negative in front of vector means "not in"
rm(ipd_resp) # No sense keeping a copy of the entire dataset around
Now start with some EDA on the training datasetipd_train. The test data will only get used after building models and want to compare their predictive abilities.
As mentioned above, the dependent variable that we are trying to predict is Total_Charges - this is the amount that the hospital submits to whomever is paying the bill for the hospital stay. This is usually an insurance company, the federal Medicare or Medicaid program, an employer who self-insurers or the patient. The Payment_Typology_1 field contains the primary payer to whom the charges are submitted. If you look at the relationship between Total_Costs and Total_Charges, you'll start to see why the economics of the US healthcare system is hard to understand.
You'll notice that ipd_train contains a few numeric fields and many factors (categorical data). You are free to use any of these fields in your regression models to predict Total_Charges.
Start by using things like ggplot2 and dplyr to explore the training dataset. You can use other packages as well. Your goal is to gain a general understanding of the variables and perhaps uncover some useful relationships that you can use in your regression models.
NOTE: In the data prep phase I made sure there were no NA values in the data frames that we are using for this assignment. So, no need to worry about that.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(coefplot)
library(reshape2)
library(scales)
library(boot)
# summary(ipd_train)
Now, it's your turn ...
# Histogram of Response/Output Variable
ggplot(data = ipd_train) + geom_histogram(aes(x = Total_Charges), binwidth = 30000, fill = "steelblue", colour="Black")
# Histogram of Predictor1/Input Numeric Variable1
ggplot(data = ipd_train) + geom_histogram(aes(x = Total_Costs), binwidth = 30000, fill = "orange", colour="Black")
# Histogram of Predictor2/Input Numeric Variable2
ggplot(data = ipd_train) + geom_histogram(aes(x = Length_of_Stay), fill = "violet", colour="Black")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Scatterplots of Total_Charges vs Total_Costs
ggplot(data = ipd_train) + geom_point(aes(y = log(Total_Charges), x = log(Total_Costs)))
# Scatterplots of Total_Charges vs Length_of_Stay
ggplot(data = ipd_train) + geom_point(aes(y = Total_Charges, x = Length_of_Stay))
# Scatterplots of Total_Charges vs Total_Costs faceted along Payment_Typology_1
ggplot(data = ipd_train) + geom_point(aes(y = Total_Charges, x = Total_Costs)) +
facet_wrap(~Payment_Typology_1)
# Scatterplots of Total_Charges vs Total_Costs faceted along Health_Service_Area
ggplot(data = ipd_train) + geom_point(aes(y = Total_Charges, x = Total_Costs, col = Health_Service_Area)) +
facet_wrap(~Health_Service_Area)
# Scatterplots of Total_Charges vs Total_Costs faceted along Age_Group
ggplot(data = ipd_train) + geom_point(aes(y = Total_Charges, x = Total_Costs, col = Age_Group)) +
facet_wrap(~Age_Group)
# Scatterplots of Total_Charges vs Total_Costs faceted along Type_of_Admission
ggplot(data = ipd_train) + geom_point(aes(y = Total_Charges, x = Total_Costs, col = Type_of_Admission)) +
facet_wrap(~Type_of_Admission)
# Histograms of Total_Charges along Patient_Disposition
ggplot(data = ipd_train) + geom_histogram(aes(x = Total_Charges, binwidth = 30000, fill = Patient_Disposition)) + scale_x_log10()
## Warning: Ignoring unknown aesthetics: binwidth
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Histograms of Total_Charges along Hospital_County
ggplot(data = ipd_train) + geom_histogram(aes(x = Total_Charges, binwidth = 3000000, fill = Hospital_County)) + scale_x_log10()
## Warning: Ignoring unknown aesthetics: binwidth
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Histograms of Total_Charges along APR_Severity_of_Illness_Desc
ggplot(data = ipd_train) + geom_histogram(aes(x = Total_Charges, binwidth = 300000, fill = APR_Severity_of_Illness_Desc)) + scale_x_log10()
## Warning: Ignoring unknown aesthetics: binwidth
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# Histograms of Total_Charges along APR_Risk_of_Mortality
ggplot(data = ipd_train) + geom_histogram(aes(x = Total_Charges, binwidth = 300000, fill = APR_Risk_of_Mortality)) + scale_x_log10()
## Warning: Ignoring unknown aesthetics: binwidth
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Now that you know a little more about the data, it's time to start building a few predictive models for Total_Charges. The error metric that we will use to evaluate the models (both for fit and for predictions) is median absolute deviation (MAD). This is nothing more than the median of the absolute value of the residuals for a fitted model.
QUESTION: What might be an advantage of using median absolute deviation instead of mean absolute deviation?
ANSWER: The possible advantage of median absolute deviation over mean absolute deviation is that outliers have less of an affect on median absolute deviation.
Obviously we want models with lower MAD values. Our ultimate goal is to create a model that predicts well on the test dataset, ipd_test.
It's always a good idea to start out with what we call the null model. This is the simplest possible model and one that other models better be able to beat. For this regression problem, the null model is simply a regression model that just has a y-intercept. If you remember some of your statistics, you won't be surprised that the best fit value for the y-intercept in this case is the mean of the response variable, Total_Charges.
# charges_lm0 <- lm(Total_Charges ~ 1, data = ipd_train)
# summary(charges_lm0)
# # Compute the MAD value
# median(abs(charges_lm0$residuals))
It's not hard to create regression models with smaller MAD values than this. :)
Just to give you a benchmark, I built a model on the training set that had a MAD value of 7270.340. Again, this is just the median of the absolute values of the residuals of the fitted model. Later when I used this model on the test data, I got a MAD of ... well, I'll tell you a little later.
# Correlation Matrix
# head(ipd_train)
# str(ipd_train)
# Correlation between Numeric Predictors
cor(ipd_train$Total_Charges, ipd_train$Total_Costs)
## [1] 0.8621902
cor(ipd_train$Total_Charges, ipd_train$Length_of_Stay)
## [1] 0.7874142
There seems to be a positive relationship between Total_Charges and Total_Costs and also between Total_Charges and the Length_of_Stay.
# Selecting Just the Numeric Predictors to Build the Correlation Matrix
correlationbuild1 <- ipd_train %>%
select(Facility_Name, Length_of_Stay, Total_Charges, Total_Costs)
head(correlationbuild1)
## # A tibble: 6 x 4
## Facility_Name Length_of_Stay Total_Charges Total_Costs
## <fct> <int> <dbl> <dbl>
## 1 Olean General Hospital 4 11304 4584
## 2 Buffalo General Hospital 1 7512 2746
## 3 Buffalo General Hospital 1 6709 2561
## 4 Women And Children's Hospital … 4 21882 13889
## 5 Women And Children's Hospital … 1 4584 2743
## 6 Women And Children's Hospital … 1 7020 2234
# Correlation Matrix
cor(correlationbuild1[, c(2, 3:4)])
## Length_of_Stay Total_Charges Total_Costs
## Length_of_Stay 1.0000000 0.7874142 0.7847404
## Total_Charges 0.7874142 1.0000000 0.8621902
## Total_Costs 0.7847404 0.8621902 1.0000000
# Putting the Correlation Matrix in a Dataframe
ipdtrainCor <- cor(correlationbuild1[, c(2, 3:4)])
# Melting the Data for ease of plotting
correlationbuild1Melt <- melt(ipdtrainCor, varnames=c("x", "y"), value.name = "Correlation")
# Ordering the Correlation According to their Value
correlationbuild1Melt <- correlationbuild1Melt[order(correlationbuild1Melt$Correlation), ]
# Display the Melted Data
correlationbuild1Melt
## x y Correlation
## 3 Total_Costs Length_of_Stay 0.7847404
## 7 Length_of_Stay Total_Costs 0.7847404
## 2 Total_Charges Length_of_Stay 0.7874142
## 4 Length_of_Stay Total_Charges 0.7874142
## 6 Total_Costs Total_Charges 0.8621902
## 8 Total_Charges Total_Costs 0.8621902
## 1 Length_of_Stay Length_of_Stay 1.0000000
## 5 Total_Charges Total_Charges 1.0000000
## 9 Total_Costs Total_Costs 1.0000000
# Heatmap of Correlation For Numerical Predictors
ggplot(correlationbuild1Melt, aes(x=x, y=y)) + geom_tile(aes(fill=Correlation)) + scale_fill_gradient2(low = muted("red"), mid = "white", high = "violet", guide = guide_colorbar(ticks = FALSE, barheight = 10), limits=c(-1, 1)) + theme_minimal() + labs(x=NULL, y = NULL)
Using the information you've gained from reading about the data and doing some EDA, build several regression models and compute the MAD from each. Summarize your results in terms of which model or models appear to fit well.
# # Model 1: Build to Understand the effect of the Predictors on the Response Variable
# totalCharges1 <- lm(Total_Charges ~ Total_Costs + Age_Group + Gender + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Patient_Disposition + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_train)
#
# summary(totalCharges1)
#
# # Compute the MAD value
# median(abs(totalCharges1$residuals))
As, we can see that Gender is not significant. Let's try to fit our Model a little better, by removing the Predictor Gender
# # Model 2: Build to Understand the effect of the Predictors on the Response Variable
# totalCharges2 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Patient_Disposition + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_train)
#
# summary(totalCharges2)
#
# # Compute the MAD value
# median(abs(totalCharges2$residuals))
Since, majority of the Co-efficients for the Patient_Disposition consists of an insignificant p-value. Let's try to fit the Model and check the MAD to check if removing the Predictor Patient_Disposition will be a good idea.
# # Model 3: Build to Understand the effect of the Predictors on the Response Variable
# totalCharges3 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_train)
#
# summary(totalCharges3)
#
# # Compute the MAD value
# median(abs(totalCharges3$residuals))
Yup, looks like MAD value did get reduced. Apparently our Model Fit just got better than the previous Model 2.
# # Model 4: Build to Understand the effect of the Predictors on the Response Variable, by removing APR_DRG_Desc for viewing the Correlation Matrix
# totalCharges4 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_train)
#
# summary(totalCharges4)
#
# # Compute the MAD value
# median(abs(totalCharges4$residuals))
In the above Model, looks like Fitting the Model upon removing the APR_DRG_Desc Predictors caused the Model MAD value to get high. So may be APR_DRG_Desc is a significant Predictor. Hence removing the Predictor APR_DRG_Desc might not be a good idea. So apparently our Model TotalCharges3 is still going strong. Let's try to build some more Models.
# # Model 5: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & considering the Predictors Total_Costs, Length_of_Stay, Health_Service_Area, Type_of_Admission, Payment_Typology_1, and Age_Group by removing the other Predictors for Model Fitting
#
# totalCharges5 <- lm(Total_Charges ~ Total_Costs + Length_of_Stay + Health_Service_Area + Type_of_Admission + Payment_Typology_1 + Age_Group, data = ipd_train)
#
# summary(totalCharges5)
#
# # Compute the MAD value
# median(abs(totalCharges5$residuals))
#
# # Model Visualization
# coefplot(totalCharges5)
#
# # Model Visualization Considering Removing Some Insignificant Predictors
# coefplot(totalCharges5,predictors=c("Length_of_Stay","Total_Costs", "Health_Service_Area", "Type_of_Admission", "Payment_Typology_1"))
In terms of our Non-additive Models, this one looks to have the best fit, with the least MAD of all of the previous Models. From the Coefficient Plot some of the significant Predictors that might have influenced the Model parameters are Type_of_AdmissionTrauma which makes sense that if the Patient is getting admitted for trauma related factors then the Total_Charges would impact. Similarly the Total_Charges would also depend upon the location area of the health service area provider, such as Health_Service_AreaNew York City, Health_Service_AreaLong Island, Health_Service_AreaHudsonValley will have a significant impact on the Total_Charges.
# # Model 6: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Length_of_Stay * Payment_Typology_1 for Model Fitting
#
# totalCharges6 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 + Type_of_Admission + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_train)
#
# summary(totalCharges6)
#
# # Compute the MAD value
# median(abs(totalCharges6$residuals))
This is our first additive Model where we wanted to see the interaction between the patient's Length_of_Stay and the Payment_Typology_1 along with some other Predictors to see the Model significance. The MAD value got a significant reduction, from Model 4, but got higher from Model 5. Let's try to see if we can get any better with the MAD.
# # Model 7: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Length_of_Stay * Payment_Typology_1 * Total_Costs for Model Fitting.
#
# totalCharges7 <- lm(Total_Charges ~ Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 * Total_Costs + Type_of_Admission + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_train)
#
# summary(totalCharges7)
#
# # Compute the MAD value
# median(abs(totalCharges7$residuals))
In this Model we wanted to see the interaction amongst the patient's Length_of_Stay, Payment_Typology_1 which is nothing but the kind of Medical Insurance coverage along with the Total_Costs. So far our best fit Model with a MAD of 7245.633! That's pretty awesome. Let's see if we can bring the MAD further down by trying to fit some more Models.
# # Model 8: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Length_of_Stay * Payment_Typology_1 * Total_Costs along with Type_of_Admission * APR_Severity_of_Illness_Desc for Model Fitting.
#
# totalCharges8 <- lm(Total_Charges ~ Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 * Total_Costs + Type_of_Admission * APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train)
#
# summary(totalCharges8)
#
# # Compute the MAD value
# median(abs(totalCharges8$residuals))
In this Model we wanted to see the interaction between the patients' Type_of_Admission and APR_Severity_of_Illness_Desc along with other Predictors. However, our MAD got a little hike here, that we don't like. :( Let's try to build some more Models then!
# Model 9: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Health_Service_Area * Length_of_Stay * Total_Costs along with Type_of_Admission * Payment_Typology_1 for Model Fitting.
totalCharges9 <- lm(Total_Charges ~ Age_Group + Health_Service_Area * Length_of_Stay * Total_Costs + Type_of_Admission * Payment_Typology_1 + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train)
summary(totalCharges9)
##
## Call:
## lm(formula = Total_Charges ~ Age_Group + Health_Service_Area *
## Length_of_Stay * Total_Costs + Type_of_Admission * Payment_Typology_1 +
## APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -714032 -6380 -321 5481 944842
##
## Coefficients: (10 not defined because of singularities)
## Estimate
## (Intercept) 2.616e+04
## Age_Group.L -9.561e+02
## Age_Group.Q -2.533e+03
## Age_Group.C 1.357e+03
## Age_Group^4 -7.471e+02
## Health_Service_AreaCentral NY -2.992e+02
## Health_Service_AreaFinger Lakes 2.949e+02
## Health_Service_AreaHudson Valley 4.248e+03
## Health_Service_AreaLong Island 1.843e+03
## Health_Service_AreaNew York City 3.275e+03
## Health_Service_AreaSouthern Tier 7.553e+02
## Health_Service_AreaWestern NY -4.413e+03
## Length_of_Stay 8.660e+02
## Total_Costs 1.930e+00
## Type_of_AdmissionEmergency -7.332e+03
## Type_of_AdmissionNewborn -1.619e+05
## Type_of_AdmissionNot Available -1.020e+04
## Type_of_AdmissionTrauma 1.028e+03
## Type_of_AdmissionUrgent 5.450e+02
## Payment_Typology_1Department of Corrections -1.050e+04
## Payment_Typology_1Federal/State/Local/VA -1.020e+04
## Payment_Typology_1Managed Care, Unspecified -8.825e+02
## Payment_Typology_1Medicaid -1.158e+04
## Payment_Typology_1Medicare -3.468e+03
## Payment_Typology_1Miscellaneous/Other -1.930e+04
## Payment_Typology_1Private Health Insurance 5.201e+02
## Payment_Typology_1Self-Pay -1.713e+04
## Payment_Typology_1Unknown -1.101e+04
## APR_Severity_of_Illness_DescMajor -8.987e+03
## APR_Severity_of_Illness_DescMinor -1.217e+04
## APR_Severity_of_Illness_DescModerate -1.080e+04
## APR_Risk_of_MortalityMajor -3.685e+03
## APR_Risk_of_MortalityMinor -4.779e+03
## APR_Risk_of_MortalityModerate -3.997e+03
## Health_Service_AreaCentral NY:Length_of_Stay -1.311e+03
## Health_Service_AreaFinger Lakes:Length_of_Stay -1.022e+03
## Health_Service_AreaHudson Valley:Length_of_Stay -1.862e+03
## Health_Service_AreaLong Island:Length_of_Stay 1.690e+03
## Health_Service_AreaNew York City:Length_of_Stay 1.913e+03
## Health_Service_AreaSouthern Tier:Length_of_Stay -2.225e+03
## Health_Service_AreaWestern NY:Length_of_Stay 1.524e+02
## Health_Service_AreaCentral NY:Total_Costs 7.768e-02
## Health_Service_AreaFinger Lakes:Total_Costs -2.897e-01
## Health_Service_AreaHudson Valley:Total_Costs 1.127e+00
## Health_Service_AreaLong Island:Total_Costs 4.992e-01
## Health_Service_AreaNew York City:Total_Costs -5.801e-01
## Health_Service_AreaSouthern Tier:Total_Costs 8.967e-01
## Health_Service_AreaWestern NY:Total_Costs -2.297e-01
## Length_of_Stay:Total_Costs 4.118e-03
## Type_of_AdmissionEmergency:Payment_Typology_1Department of Corrections 3.161e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionNot Available:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionTrauma:Payment_Typology_1Department of Corrections 1.053e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Department of Corrections -4.572e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Federal/State/Local/VA 8.628e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Federal/State/Local/VA 1.479e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Federal/State/Local/VA 2.641e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Federal/State/Local/VA 7.670e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Federal/State/Local/VA 3.891e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Managed Care, Unspecified 8.385e+02
## Type_of_AdmissionNewborn:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionNot Available:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionTrauma:Payment_Typology_1Managed Care, Unspecified 8.015e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Managed Care, Unspecified -6.749e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Medicaid 6.606e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Medicaid 1.532e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Medicaid 1.741e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Medicaid 9.709e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Medicaid 7.468e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Medicare 2.388e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Medicare 1.725e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Medicare -2.976e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Medicare 4.014e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Medicare -1.409e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Miscellaneous/Other 1.887e+04
## Type_of_AdmissionNewborn:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionNot Available:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionTrauma:Payment_Typology_1Miscellaneous/Other 2.326e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Miscellaneous/Other 9.105e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Private Health Insurance -2.546e+02
## Type_of_AdmissionNewborn:Payment_Typology_1Private Health Insurance NA
## Type_of_AdmissionNot Available:Payment_Typology_1Private Health Insurance -2.344e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Private Health Insurance -1.235e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Private Health Insurance -3.700e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Self-Pay -5.198e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Self-Pay -1.747e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Self-Pay 6.639e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Self-Pay 1.356e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Self-Pay -1.322e+04
## Type_of_AdmissionEmergency:Payment_Typology_1Unknown 6.827e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Unknown NA
## Type_of_AdmissionNot Available:Payment_Typology_1Unknown NA
## Type_of_AdmissionTrauma:Payment_Typology_1Unknown NA
## Type_of_AdmissionUrgent:Payment_Typology_1Unknown -7.652e+02
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 3.651e-04
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 9.108e-05
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 5.049e-03
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 2.217e-03
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs -3.008e-03
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 8.242e-04
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs -5.263e-03
## Std. Error
## (Intercept) 9.828e+02
## Age_Group.L 2.557e+02
## Age_Group.Q 2.090e+02
## Age_Group.C 2.681e+02
## Age_Group^4 2.547e+02
## Health_Service_AreaCentral NY 5.627e+02
## Health_Service_AreaFinger Lakes 5.742e+02
## Health_Service_AreaHudson Valley 5.223e+02
## Health_Service_AreaLong Island 5.026e+02
## Health_Service_AreaNew York City 4.322e+02
## Health_Service_AreaSouthern Tier 1.052e+03
## Health_Service_AreaWestern NY 5.589e+02
## Length_of_Stay 7.945e+01
## Total_Costs 3.224e-02
## Type_of_AdmissionEmergency 8.663e+02
## Type_of_AdmissionNewborn 1.495e+04
## Type_of_AdmissionNot Available 7.831e+03
## Type_of_AdmissionTrauma 5.450e+03
## Type_of_AdmissionUrgent 1.293e+03
## Payment_Typology_1Department of Corrections 6.720e+03
## Payment_Typology_1Federal/State/Local/VA 3.981e+03
## Payment_Typology_1Managed Care, Unspecified 1.883e+03
## Payment_Typology_1Medicaid 1.124e+03
## Payment_Typology_1Medicare 9.231e+02
## Payment_Typology_1Miscellaneous/Other 2.298e+03
## Payment_Typology_1Private Health Insurance 1.097e+03
## Payment_Typology_1Self-Pay 3.217e+03
## Payment_Typology_1Unknown 5.699e+03
## APR_Severity_of_Illness_DescMajor 3.092e+02
## APR_Severity_of_Illness_DescMinor 4.200e+02
## APR_Severity_of_Illness_DescModerate 3.711e+02
## APR_Risk_of_MortalityMajor 3.433e+02
## APR_Risk_of_MortalityMinor 4.442e+02
## APR_Risk_of_MortalityModerate 3.915e+02
## Health_Service_AreaCentral NY:Length_of_Stay 1.217e+02
## Health_Service_AreaFinger Lakes:Length_of_Stay 1.183e+02
## Health_Service_AreaHudson Valley:Length_of_Stay 1.000e+02
## Health_Service_AreaLong Island:Length_of_Stay 9.851e+01
## Health_Service_AreaNew York City:Length_of_Stay 8.317e+01
## Health_Service_AreaSouthern Tier:Length_of_Stay 2.730e+02
## Health_Service_AreaWestern NY:Length_of_Stay 1.104e+02
## Health_Service_AreaCentral NY:Total_Costs 5.188e-02
## Health_Service_AreaFinger Lakes:Total_Costs 5.520e-02
## Health_Service_AreaHudson Valley:Total_Costs 4.076e-02
## Health_Service_AreaLong Island:Total_Costs 3.999e-02
## Health_Service_AreaNew York City:Total_Costs 3.288e-02
## Health_Service_AreaSouthern Tier:Total_Costs 1.487e-01
## Health_Service_AreaWestern NY:Total_Costs 4.573e-02
## Length_of_Stay:Total_Costs 6.075e-04
## Type_of_AdmissionEmergency:Payment_Typology_1Department of Corrections 7.076e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionNot Available:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionTrauma:Payment_Typology_1Department of Corrections 1.722e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Department of Corrections 1.459e+04
## Type_of_AdmissionEmergency:Payment_Typology_1Federal/State/Local/VA 4.159e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Federal/State/Local/VA 2.393e+04
## Type_of_AdmissionNot Available:Payment_Typology_1Federal/State/Local/VA 2.727e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Federal/State/Local/VA 1.635e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Federal/State/Local/VA 5.657e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Managed Care, Unspecified 2.088e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionNot Available:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionTrauma:Payment_Typology_1Managed Care, Unspecified 1.289e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Managed Care, Unspecified 3.021e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Medicaid 1.165e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Medicaid 1.830e+04
## Type_of_AdmissionNot Available:Payment_Typology_1Medicaid 1.398e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Medicaid 6.198e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Medicaid 1.660e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Medicare 9.629e+02
## Type_of_AdmissionNewborn:Payment_Typology_1Medicare 2.112e+04
## Type_of_AdmissionNot Available:Payment_Typology_1Medicare 9.191e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Medicare 5.959e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Medicare 1.445e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Miscellaneous/Other 2.469e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionNot Available:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionTrauma:Payment_Typology_1Miscellaneous/Other 6.395e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Miscellaneous/Other 3.822e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Private Health Insurance 1.159e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Private Health Insurance NA
## Type_of_AdmissionNot Available:Payment_Typology_1Private Health Insurance 1.166e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Private Health Insurance 6.712e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Private Health Insurance 1.795e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Self-Pay 3.266e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Self-Pay 3.000e+04
## Type_of_AdmissionNot Available:Payment_Typology_1Self-Pay 2.717e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Self-Pay 1.000e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Self-Pay 4.173e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Unknown 5.851e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Unknown NA
## Type_of_AdmissionNot Available:Payment_Typology_1Unknown NA
## Type_of_AdmissionTrauma:Payment_Typology_1Unknown NA
## Type_of_AdmissionUrgent:Payment_Typology_1Unknown 8.283e+03
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 7.885e-04
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 8.129e-04
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 6.915e-04
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 6.898e-04
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs 6.182e-04
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 2.792e-03
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs 7.531e-04
## t value
## (Intercept) 26.624
## Age_Group.L -3.739
## Age_Group.Q -12.121
## Age_Group.C 5.060
## Age_Group^4 -2.933
## Health_Service_AreaCentral NY -0.532
## Health_Service_AreaFinger Lakes 0.514
## Health_Service_AreaHudson Valley 8.134
## Health_Service_AreaLong Island 3.668
## Health_Service_AreaNew York City 7.577
## Health_Service_AreaSouthern Tier 0.718
## Health_Service_AreaWestern NY -7.896
## Length_of_Stay 10.900
## Total_Costs 59.884
## Type_of_AdmissionEmergency -8.463
## Type_of_AdmissionNewborn -10.829
## Type_of_AdmissionNot Available -1.302
## Type_of_AdmissionTrauma 0.189
## Type_of_AdmissionUrgent 0.422
## Payment_Typology_1Department of Corrections -1.563
## Payment_Typology_1Federal/State/Local/VA -2.562
## Payment_Typology_1Managed Care, Unspecified -0.469
## Payment_Typology_1Medicaid -10.306
## Payment_Typology_1Medicare -3.756
## Payment_Typology_1Miscellaneous/Other -8.400
## Payment_Typology_1Private Health Insurance 0.474
## Payment_Typology_1Self-Pay -5.325
## Payment_Typology_1Unknown -1.932
## APR_Severity_of_Illness_DescMajor -29.064
## APR_Severity_of_Illness_DescMinor -28.984
## APR_Severity_of_Illness_DescModerate -29.111
## APR_Risk_of_MortalityMajor -10.736
## APR_Risk_of_MortalityMinor -10.759
## APR_Risk_of_MortalityModerate -10.209
## Health_Service_AreaCentral NY:Length_of_Stay -10.770
## Health_Service_AreaFinger Lakes:Length_of_Stay -8.640
## Health_Service_AreaHudson Valley:Length_of_Stay -18.615
## Health_Service_AreaLong Island:Length_of_Stay 17.158
## Health_Service_AreaNew York City:Length_of_Stay 23.001
## Health_Service_AreaSouthern Tier:Length_of_Stay -8.151
## Health_Service_AreaWestern NY:Length_of_Stay 1.380
## Health_Service_AreaCentral NY:Total_Costs 1.497
## Health_Service_AreaFinger Lakes:Total_Costs -5.249
## Health_Service_AreaHudson Valley:Total_Costs 27.642
## Health_Service_AreaLong Island:Total_Costs 12.485
## Health_Service_AreaNew York City:Total_Costs -17.644
## Health_Service_AreaSouthern Tier:Total_Costs 6.030
## Health_Service_AreaWestern NY:Total_Costs -5.023
## Length_of_Stay:Total_Costs 6.779
## Type_of_AdmissionEmergency:Payment_Typology_1Department of Corrections 0.447
## Type_of_AdmissionNewborn:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionNot Available:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionTrauma:Payment_Typology_1Department of Corrections 0.612
## Type_of_AdmissionUrgent:Payment_Typology_1Department of Corrections -0.313
## Type_of_AdmissionEmergency:Payment_Typology_1Federal/State/Local/VA 2.074
## Type_of_AdmissionNewborn:Payment_Typology_1Federal/State/Local/VA 6.181
## Type_of_AdmissionNot Available:Payment_Typology_1Federal/State/Local/VA 0.969
## Type_of_AdmissionTrauma:Payment_Typology_1Federal/State/Local/VA 0.469
## Type_of_AdmissionUrgent:Payment_Typology_1Federal/State/Local/VA 0.688
## Type_of_AdmissionEmergency:Payment_Typology_1Managed Care, Unspecified 0.402
## Type_of_AdmissionNewborn:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionNot Available:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionTrauma:Payment_Typology_1Managed Care, Unspecified 0.622
## Type_of_AdmissionUrgent:Payment_Typology_1Managed Care, Unspecified -2.234
## Type_of_AdmissionEmergency:Payment_Typology_1Medicaid 5.671
## Type_of_AdmissionNewborn:Payment_Typology_1Medicaid 8.368
## Type_of_AdmissionNot Available:Payment_Typology_1Medicaid 1.246
## Type_of_AdmissionTrauma:Payment_Typology_1Medicaid 1.567
## Type_of_AdmissionUrgent:Payment_Typology_1Medicaid 4.498
## Type_of_AdmissionEmergency:Payment_Typology_1Medicare 2.480
## Type_of_AdmissionNewborn:Payment_Typology_1Medicare 8.166
## Type_of_AdmissionNot Available:Payment_Typology_1Medicare -0.324
## Type_of_AdmissionTrauma:Payment_Typology_1Medicare 0.674
## Type_of_AdmissionUrgent:Payment_Typology_1Medicare -0.975
## Type_of_AdmissionEmergency:Payment_Typology_1Miscellaneous/Other 7.643
## Type_of_AdmissionNewborn:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionNot Available:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionTrauma:Payment_Typology_1Miscellaneous/Other 3.637
## Type_of_AdmissionUrgent:Payment_Typology_1Miscellaneous/Other 2.382
## Type_of_AdmissionEmergency:Payment_Typology_1Private Health Insurance -0.220
## Type_of_AdmissionNewborn:Payment_Typology_1Private Health Insurance NA
## Type_of_AdmissionNot Available:Payment_Typology_1Private Health Insurance -0.201
## Type_of_AdmissionTrauma:Payment_Typology_1Private Health Insurance -0.184
## Type_of_AdmissionUrgent:Payment_Typology_1Private Health Insurance -2.061
## Type_of_AdmissionEmergency:Payment_Typology_1Self-Pay -1.592
## Type_of_AdmissionNewborn:Payment_Typology_1Self-Pay -5.824
## Type_of_AdmissionNot Available:Payment_Typology_1Self-Pay 0.244
## Type_of_AdmissionTrauma:Payment_Typology_1Self-Pay 1.356
## Type_of_AdmissionUrgent:Payment_Typology_1Self-Pay -3.169
## Type_of_AdmissionEmergency:Payment_Typology_1Unknown 1.167
## Type_of_AdmissionNewborn:Payment_Typology_1Unknown NA
## Type_of_AdmissionNot Available:Payment_Typology_1Unknown NA
## Type_of_AdmissionTrauma:Payment_Typology_1Unknown NA
## Type_of_AdmissionUrgent:Payment_Typology_1Unknown -0.092
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 0.463
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 0.112
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 7.302
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 3.214
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs -4.865
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 0.295
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs -6.988
## Pr(>|t|)
## (Intercept) < 2e-16
## Age_Group.L 0.000185
## Age_Group.Q < 2e-16
## Age_Group.C 4.20e-07
## Age_Group^4 0.003356
## Health_Service_AreaCentral NY 0.594855
## Health_Service_AreaFinger Lakes 0.607533
## Health_Service_AreaHudson Valley 4.20e-16
## Health_Service_AreaLong Island 0.000245
## Health_Service_AreaNew York City 3.55e-14
## Health_Service_AreaSouthern Tier 0.472563
## Health_Service_AreaWestern NY 2.90e-15
## Length_of_Stay < 2e-16
## Total_Costs < 2e-16
## Type_of_AdmissionEmergency < 2e-16
## Type_of_AdmissionNewborn < 2e-16
## Type_of_AdmissionNot Available 0.192970
## Type_of_AdmissionTrauma 0.850451
## Type_of_AdmissionUrgent 0.673348
## Payment_Typology_1Department of Corrections 0.118138
## Payment_Typology_1Federal/State/Local/VA 0.010398
## Payment_Typology_1Managed Care, Unspecified 0.639360
## Payment_Typology_1Medicaid < 2e-16
## Payment_Typology_1Medicare 0.000172
## Payment_Typology_1Miscellaneous/Other < 2e-16
## Payment_Typology_1Private Health Insurance 0.635534
## Payment_Typology_1Self-Pay 1.01e-07
## Payment_Typology_1Unknown 0.053412
## APR_Severity_of_Illness_DescMajor < 2e-16
## APR_Severity_of_Illness_DescMinor < 2e-16
## APR_Severity_of_Illness_DescModerate < 2e-16
## APR_Risk_of_MortalityMajor < 2e-16
## APR_Risk_of_MortalityMinor < 2e-16
## APR_Risk_of_MortalityModerate < 2e-16
## Health_Service_AreaCentral NY:Length_of_Stay < 2e-16
## Health_Service_AreaFinger Lakes:Length_of_Stay < 2e-16
## Health_Service_AreaHudson Valley:Length_of_Stay < 2e-16
## Health_Service_AreaLong Island:Length_of_Stay < 2e-16
## Health_Service_AreaNew York City:Length_of_Stay < 2e-16
## Health_Service_AreaSouthern Tier:Length_of_Stay 3.64e-16
## Health_Service_AreaWestern NY:Length_of_Stay 0.167635
## Health_Service_AreaCentral NY:Total_Costs 0.134309
## Health_Service_AreaFinger Lakes:Total_Costs 1.54e-07
## Health_Service_AreaHudson Valley:Total_Costs < 2e-16
## Health_Service_AreaLong Island:Total_Costs < 2e-16
## Health_Service_AreaNew York City:Total_Costs < 2e-16
## Health_Service_AreaSouthern Tier:Total_Costs 1.65e-09
## Health_Service_AreaWestern NY:Total_Costs 5.10e-07
## Length_of_Stay:Total_Costs 1.21e-11
## Type_of_AdmissionEmergency:Payment_Typology_1Department of Corrections 0.655088
## Type_of_AdmissionNewborn:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionNot Available:Payment_Typology_1Department of Corrections NA
## Type_of_AdmissionTrauma:Payment_Typology_1Department of Corrections 0.540798
## Type_of_AdmissionUrgent:Payment_Typology_1Department of Corrections 0.754042
## Type_of_AdmissionEmergency:Payment_Typology_1Federal/State/Local/VA 0.038040
## Type_of_AdmissionNewborn:Payment_Typology_1Federal/State/Local/VA 6.38e-10
## Type_of_AdmissionNot Available:Payment_Typology_1Federal/State/Local/VA 0.332694
## Type_of_AdmissionTrauma:Payment_Typology_1Federal/State/Local/VA 0.638931
## Type_of_AdmissionUrgent:Payment_Typology_1Federal/State/Local/VA 0.491517
## Type_of_AdmissionEmergency:Payment_Typology_1Managed Care, Unspecified 0.688008
## Type_of_AdmissionNewborn:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionNot Available:Payment_Typology_1Managed Care, Unspecified NA
## Type_of_AdmissionTrauma:Payment_Typology_1Managed Care, Unspecified 0.533935
## Type_of_AdmissionUrgent:Payment_Typology_1Managed Care, Unspecified 0.025458
## Type_of_AdmissionEmergency:Payment_Typology_1Medicaid 1.42e-08
## Type_of_AdmissionNewborn:Payment_Typology_1Medicaid < 2e-16
## Type_of_AdmissionNot Available:Payment_Typology_1Medicaid 0.212938
## Type_of_AdmissionTrauma:Payment_Typology_1Medicaid 0.117230
## Type_of_AdmissionUrgent:Payment_Typology_1Medicaid 6.86e-06
## Type_of_AdmissionEmergency:Payment_Typology_1Medicare 0.013129
## Type_of_AdmissionNewborn:Payment_Typology_1Medicare 3.22e-16
## Type_of_AdmissionNot Available:Payment_Typology_1Medicare 0.746133
## Type_of_AdmissionTrauma:Payment_Typology_1Medicare 0.500622
## Type_of_AdmissionUrgent:Payment_Typology_1Medicare 0.329599
## Type_of_AdmissionEmergency:Payment_Typology_1Miscellaneous/Other 2.14e-14
## Type_of_AdmissionNewborn:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionNot Available:Payment_Typology_1Miscellaneous/Other NA
## Type_of_AdmissionTrauma:Payment_Typology_1Miscellaneous/Other 0.000276
## Type_of_AdmissionUrgent:Payment_Typology_1Miscellaneous/Other 0.017201
## Type_of_AdmissionEmergency:Payment_Typology_1Private Health Insurance 0.826175
## Type_of_AdmissionNewborn:Payment_Typology_1Private Health Insurance NA
## Type_of_AdmissionNot Available:Payment_Typology_1Private Health Insurance 0.840676
## Type_of_AdmissionTrauma:Payment_Typology_1Private Health Insurance 0.854057
## Type_of_AdmissionUrgent:Payment_Typology_1Private Health Insurance 0.039279
## Type_of_AdmissionEmergency:Payment_Typology_1Self-Pay 0.111420
## Type_of_AdmissionNewborn:Payment_Typology_1Self-Pay 5.77e-09
## Type_of_AdmissionNot Available:Payment_Typology_1Self-Pay 0.806943
## Type_of_AdmissionTrauma:Payment_Typology_1Self-Pay 0.175179
## Type_of_AdmissionUrgent:Payment_Typology_1Self-Pay 0.001530
## Type_of_AdmissionEmergency:Payment_Typology_1Unknown 0.243299
## Type_of_AdmissionNewborn:Payment_Typology_1Unknown NA
## Type_of_AdmissionNot Available:Payment_Typology_1Unknown NA
## Type_of_AdmissionTrauma:Payment_Typology_1Unknown NA
## Type_of_AdmissionUrgent:Payment_Typology_1Unknown 0.926394
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 0.643308
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 0.910794
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 2.85e-13
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 0.001310
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs 1.14e-06
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 0.767879
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs 2.81e-12
##
## (Intercept) ***
## Age_Group.L ***
## Age_Group.Q ***
## Age_Group.C ***
## Age_Group^4 **
## Health_Service_AreaCentral NY
## Health_Service_AreaFinger Lakes
## Health_Service_AreaHudson Valley ***
## Health_Service_AreaLong Island ***
## Health_Service_AreaNew York City ***
## Health_Service_AreaSouthern Tier
## Health_Service_AreaWestern NY ***
## Length_of_Stay ***
## Total_Costs ***
## Type_of_AdmissionEmergency ***
## Type_of_AdmissionNewborn ***
## Type_of_AdmissionNot Available
## Type_of_AdmissionTrauma
## Type_of_AdmissionUrgent
## Payment_Typology_1Department of Corrections
## Payment_Typology_1Federal/State/Local/VA *
## Payment_Typology_1Managed Care, Unspecified
## Payment_Typology_1Medicaid ***
## Payment_Typology_1Medicare ***
## Payment_Typology_1Miscellaneous/Other ***
## Payment_Typology_1Private Health Insurance
## Payment_Typology_1Self-Pay ***
## Payment_Typology_1Unknown .
## APR_Severity_of_Illness_DescMajor ***
## APR_Severity_of_Illness_DescMinor ***
## APR_Severity_of_Illness_DescModerate ***
## APR_Risk_of_MortalityMajor ***
## APR_Risk_of_MortalityMinor ***
## APR_Risk_of_MortalityModerate ***
## Health_Service_AreaCentral NY:Length_of_Stay ***
## Health_Service_AreaFinger Lakes:Length_of_Stay ***
## Health_Service_AreaHudson Valley:Length_of_Stay ***
## Health_Service_AreaLong Island:Length_of_Stay ***
## Health_Service_AreaNew York City:Length_of_Stay ***
## Health_Service_AreaSouthern Tier:Length_of_Stay ***
## Health_Service_AreaWestern NY:Length_of_Stay
## Health_Service_AreaCentral NY:Total_Costs
## Health_Service_AreaFinger Lakes:Total_Costs ***
## Health_Service_AreaHudson Valley:Total_Costs ***
## Health_Service_AreaLong Island:Total_Costs ***
## Health_Service_AreaNew York City:Total_Costs ***
## Health_Service_AreaSouthern Tier:Total_Costs ***
## Health_Service_AreaWestern NY:Total_Costs ***
## Length_of_Stay:Total_Costs ***
## Type_of_AdmissionEmergency:Payment_Typology_1Department of Corrections
## Type_of_AdmissionNewborn:Payment_Typology_1Department of Corrections
## Type_of_AdmissionNot Available:Payment_Typology_1Department of Corrections
## Type_of_AdmissionTrauma:Payment_Typology_1Department of Corrections
## Type_of_AdmissionUrgent:Payment_Typology_1Department of Corrections
## Type_of_AdmissionEmergency:Payment_Typology_1Federal/State/Local/VA *
## Type_of_AdmissionNewborn:Payment_Typology_1Federal/State/Local/VA ***
## Type_of_AdmissionNot Available:Payment_Typology_1Federal/State/Local/VA
## Type_of_AdmissionTrauma:Payment_Typology_1Federal/State/Local/VA
## Type_of_AdmissionUrgent:Payment_Typology_1Federal/State/Local/VA
## Type_of_AdmissionEmergency:Payment_Typology_1Managed Care, Unspecified
## Type_of_AdmissionNewborn:Payment_Typology_1Managed Care, Unspecified
## Type_of_AdmissionNot Available:Payment_Typology_1Managed Care, Unspecified
## Type_of_AdmissionTrauma:Payment_Typology_1Managed Care, Unspecified
## Type_of_AdmissionUrgent:Payment_Typology_1Managed Care, Unspecified *
## Type_of_AdmissionEmergency:Payment_Typology_1Medicaid ***
## Type_of_AdmissionNewborn:Payment_Typology_1Medicaid ***
## Type_of_AdmissionNot Available:Payment_Typology_1Medicaid
## Type_of_AdmissionTrauma:Payment_Typology_1Medicaid
## Type_of_AdmissionUrgent:Payment_Typology_1Medicaid ***
## Type_of_AdmissionEmergency:Payment_Typology_1Medicare *
## Type_of_AdmissionNewborn:Payment_Typology_1Medicare ***
## Type_of_AdmissionNot Available:Payment_Typology_1Medicare
## Type_of_AdmissionTrauma:Payment_Typology_1Medicare
## Type_of_AdmissionUrgent:Payment_Typology_1Medicare
## Type_of_AdmissionEmergency:Payment_Typology_1Miscellaneous/Other ***
## Type_of_AdmissionNewborn:Payment_Typology_1Miscellaneous/Other
## Type_of_AdmissionNot Available:Payment_Typology_1Miscellaneous/Other
## Type_of_AdmissionTrauma:Payment_Typology_1Miscellaneous/Other ***
## Type_of_AdmissionUrgent:Payment_Typology_1Miscellaneous/Other *
## Type_of_AdmissionEmergency:Payment_Typology_1Private Health Insurance
## Type_of_AdmissionNewborn:Payment_Typology_1Private Health Insurance
## Type_of_AdmissionNot Available:Payment_Typology_1Private Health Insurance
## Type_of_AdmissionTrauma:Payment_Typology_1Private Health Insurance
## Type_of_AdmissionUrgent:Payment_Typology_1Private Health Insurance *
## Type_of_AdmissionEmergency:Payment_Typology_1Self-Pay
## Type_of_AdmissionNewborn:Payment_Typology_1Self-Pay ***
## Type_of_AdmissionNot Available:Payment_Typology_1Self-Pay
## Type_of_AdmissionTrauma:Payment_Typology_1Self-Pay
## Type_of_AdmissionUrgent:Payment_Typology_1Self-Pay **
## Type_of_AdmissionEmergency:Payment_Typology_1Unknown
## Type_of_AdmissionNewborn:Payment_Typology_1Unknown
## Type_of_AdmissionNot Available:Payment_Typology_1Unknown
## Type_of_AdmissionTrauma:Payment_Typology_1Unknown
## Type_of_AdmissionUrgent:Payment_Typology_1Unknown
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs ***
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs **
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs ***
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 25820 on 137229 degrees of freedom
## Multiple R-squared: 0.836, Adjusted R-squared: 0.8359
## F-statistic: 7772 on 90 and 137229 DF, p-value: < 2.2e-16
# Compute the MAD value
madA9 <- median(abs(totalCharges9$residuals))
madA9
## [1] 5932.954
In this Model, we tried to see the interaction amongst the patients' Length_of_Stay, the Health_Service_Area, and the Total_Costs along with the interaction between the Type_of_Admission and the Payment_Typology_1. Some of the other Predictors that we considered for building this Models are patients' Age_Group, APR_Severity_of_Illness_Desc, and APR_Risk_of_Mortality. Needless to say we got our another significant Model with a low MAD!
# Model 10: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Health_Service_Area * Length_of_Stay * Total_Costs along with Payment_Typology_1 * Age_Group for Model Fitting
totalCharges10 <- lm(Total_Charges ~ Health_Service_Area * Length_of_Stay * Total_Costs + Type_of_Admission + Payment_Typology_1 * Age_Group + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train)
summary(totalCharges10)
##
## Call:
## lm(formula = Total_Charges ~ Health_Service_Area * Length_of_Stay *
## Total_Costs + Type_of_Admission + Payment_Typology_1 * Age_Group +
## APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -711676 -6355 -283 5454 948246
##
## Coefficients: (1 not defined because of singularities)
## Estimate
## (Intercept) 2.373e+04
## Health_Service_AreaCentral NY -3.444e+02
## Health_Service_AreaFinger Lakes 3.455e+02
## Health_Service_AreaHudson Valley 4.267e+03
## Health_Service_AreaLong Island 1.782e+03
## Health_Service_AreaNew York City 3.220e+03
## Health_Service_AreaSouthern Tier 1.092e+03
## Health_Service_AreaWestern NY -4.603e+03
## Length_of_Stay 8.452e+02
## Total_Costs 1.937e+00
## Type_of_AdmissionEmergency -4.674e+03
## Type_of_AdmissionNewborn -5.992e+04
## Type_of_AdmissionNot Available -9.634e+03
## Type_of_AdmissionTrauma 6.981e+03
## Type_of_AdmissionUrgent 6.717e+02
## Payment_Typology_1Department of Corrections -1.120e+04
## Payment_Typology_1Federal/State/Local/VA -1.744e+03
## Payment_Typology_1Managed Care, Unspecified -1.941e+02
## Payment_Typology_1Medicaid -5.322e+03
## Payment_Typology_1Medicare -2.217e+03
## Payment_Typology_1Miscellaneous/Other -5.559e+03
## Payment_Typology_1Private Health Insurance -2.771e+02
## Payment_Typology_1Self-Pay -1.918e+04
## Payment_Typology_1Unknown -4.392e+03
## Age_Group.L 3.429e+03
## Age_Group.Q -2.609e+03
## Age_Group.C 1.124e+03
## Age_Group^4 -1.962e+02
## APR_Severity_of_Illness_DescMajor -8.988e+03
## APR_Severity_of_Illness_DescMinor -1.220e+04
## APR_Severity_of_Illness_DescModerate -1.077e+04
## APR_Risk_of_MortalityMajor -3.650e+03
## APR_Risk_of_MortalityMinor -4.823e+03
## APR_Risk_of_MortalityModerate -3.971e+03
## Health_Service_AreaCentral NY:Length_of_Stay -1.286e+03
## Health_Service_AreaFinger Lakes:Length_of_Stay -1.003e+03
## Health_Service_AreaHudson Valley:Length_of_Stay -1.869e+03
## Health_Service_AreaLong Island:Length_of_Stay 1.700e+03
## Health_Service_AreaNew York City:Length_of_Stay 1.914e+03
## Health_Service_AreaSouthern Tier:Length_of_Stay -2.135e+03
## Health_Service_AreaWestern NY:Length_of_Stay 1.694e+02
## Health_Service_AreaCentral NY:Total_Costs 6.964e-02
## Health_Service_AreaFinger Lakes:Total_Costs -2.950e-01
## Health_Service_AreaHudson Valley:Total_Costs 1.126e+00
## Health_Service_AreaLong Island:Total_Costs 4.944e-01
## Health_Service_AreaNew York City:Total_Costs -5.718e-01
## Health_Service_AreaSouthern Tier:Total_Costs 8.524e-01
## Health_Service_AreaWestern NY:Total_Costs -2.235e-01
## Length_of_Stay:Total_Costs 4.183e-03
## Payment_Typology_1Department of Corrections:Age_Group.L 4.653e+03
## Payment_Typology_1Federal/State/Local/VA:Age_Group.L -7.633e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.L -9.533e+02
## Payment_Typology_1Medicaid:Age_Group.L -4.364e+03
## Payment_Typology_1Medicare:Age_Group.L -1.057e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.L 7.012e+03
## Payment_Typology_1Private Health Insurance:Age_Group.L -3.741e+03
## Payment_Typology_1Self-Pay:Age_Group.L -2.733e+04
## Payment_Typology_1Unknown:Age_Group.L -5.058e+03
## Payment_Typology_1Department of Corrections:Age_Group.Q -7.041e+03
## Payment_Typology_1Federal/State/Local/VA:Age_Group.Q -4.902e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.Q -7.574e+02
## Payment_Typology_1Medicaid:Age_Group.Q 1.318e+03
## Payment_Typology_1Medicare:Age_Group.Q -4.326e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.Q -9.480e+03
## Payment_Typology_1Private Health Insurance:Age_Group.Q -2.299e+03
## Payment_Typology_1Self-Pay:Age_Group.Q -7.434e+03
## Payment_Typology_1Unknown:Age_Group.Q -9.595e+02
## Payment_Typology_1Department of Corrections:Age_Group.C -1.694e+02
## Payment_Typology_1Federal/State/Local/VA:Age_Group.C -1.717e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.C 3.046e+03
## Payment_Typology_1Medicaid:Age_Group.C -1.493e+02
## Payment_Typology_1Medicare:Age_Group.C 5.719e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.C 6.242e+03
## Payment_Typology_1Private Health Insurance:Age_Group.C -1.059e+03
## Payment_Typology_1Self-Pay:Age_Group.C -2.318e+03
## Payment_Typology_1Unknown:Age_Group.C 9.250e+02
## Payment_Typology_1Department of Corrections:Age_Group^4 NA
## Payment_Typology_1Federal/State/Local/VA:Age_Group^4 3.422e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group^4 -1.035e+03
## Payment_Typology_1Medicaid:Age_Group^4 -5.003e+02
## Payment_Typology_1Medicare:Age_Group^4 -3.875e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group^4 -2.752e+03
## Payment_Typology_1Private Health Insurance:Age_Group^4 -8.905e+02
## Payment_Typology_1Self-Pay:Age_Group^4 -1.337e+03
## Payment_Typology_1Unknown:Age_Group^4 2.261e+02
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 2.877e-04
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 4.108e-05
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 4.988e-03
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 2.194e-03
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs -3.243e-03
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 4.893e-04
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs -5.445e-03
## Std. Error
## (Intercept) 6.882e+02
## Health_Service_AreaCentral NY 5.622e+02
## Health_Service_AreaFinger Lakes 5.734e+02
## Health_Service_AreaHudson Valley 5.216e+02
## Health_Service_AreaLong Island 5.020e+02
## Health_Service_AreaNew York City 4.317e+02
## Health_Service_AreaSouthern Tier 1.050e+03
## Health_Service_AreaWestern NY 5.586e+02
## Length_of_Stay 7.934e+01
## Total_Costs 3.217e-02
## Type_of_AdmissionEmergency 3.107e+02
## Type_of_AdmissionNewborn 6.685e+03
## Type_of_AdmissionNot Available 3.463e+03
## Type_of_AdmissionTrauma 1.358e+03
## Type_of_AdmissionUrgent 4.587e+02
## Payment_Typology_1Department of Corrections 7.376e+03
## Payment_Typology_1Federal/State/Local/VA 1.576e+03
## Payment_Typology_1Managed Care, Unspecified 9.985e+02
## Payment_Typology_1Medicaid 3.820e+02
## Payment_Typology_1Medicare 1.517e+03
## Payment_Typology_1Miscellaneous/Other 1.039e+03
## Payment_Typology_1Private Health Insurance 4.370e+02
## Payment_Typology_1Self-Pay 6.247e+02
## Payment_Typology_1Unknown 2.066e+03
## Age_Group.L 7.438e+02
## Age_Group.Q 7.068e+02
## Age_Group.C 7.596e+02
## Age_Group^4 6.952e+02
## APR_Severity_of_Illness_DescMajor 3.089e+02
## APR_Severity_of_Illness_DescMinor 4.196e+02
## APR_Severity_of_Illness_DescModerate 3.707e+02
## APR_Risk_of_MortalityMajor 3.429e+02
## APR_Risk_of_MortalityMinor 4.435e+02
## APR_Risk_of_MortalityModerate 3.910e+02
## Health_Service_AreaCentral NY:Length_of_Stay 1.215e+02
## Health_Service_AreaFinger Lakes:Length_of_Stay 1.181e+02
## Health_Service_AreaHudson Valley:Length_of_Stay 9.987e+01
## Health_Service_AreaLong Island:Length_of_Stay 9.835e+01
## Health_Service_AreaNew York City:Length_of_Stay 8.306e+01
## Health_Service_AreaSouthern Tier:Length_of_Stay 2.727e+02
## Health_Service_AreaWestern NY:Length_of_Stay 1.102e+02
## Health_Service_AreaCentral NY:Total_Costs 5.178e-02
## Health_Service_AreaFinger Lakes:Total_Costs 5.511e-02
## Health_Service_AreaHudson Valley:Total_Costs 4.069e-02
## Health_Service_AreaLong Island:Total_Costs 3.991e-02
## Health_Service_AreaNew York City:Total_Costs 3.281e-02
## Health_Service_AreaSouthern Tier:Total_Costs 1.485e-01
## Health_Service_AreaWestern NY:Total_Costs 4.557e-02
## Length_of_Stay:Total_Costs 6.066e-04
## Payment_Typology_1Department of Corrections:Age_Group.L 2.421e+04
## Payment_Typology_1Federal/State/Local/VA:Age_Group.L 2.959e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.L 2.087e+03
## Payment_Typology_1Medicaid:Age_Group.L 8.859e+02
## Payment_Typology_1Medicare:Age_Group.L 4.621e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.L 2.473e+03
## Payment_Typology_1Private Health Insurance:Age_Group.L 9.812e+02
## Payment_Typology_1Self-Pay:Age_Group.L 1.381e+03
## Payment_Typology_1Unknown:Age_Group.L 4.264e+03
## Payment_Typology_1Department of Corrections:Age_Group.Q 1.787e+04
## Payment_Typology_1Federal/State/Local/VA:Age_Group.Q 3.134e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.Q 2.039e+03
## Payment_Typology_1Medicaid:Age_Group.Q 8.376e+02
## Payment_Typology_1Medicare:Age_Group.Q 3.932e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.Q 2.329e+03
## Payment_Typology_1Private Health Insurance:Age_Group.Q 9.442e+02
## Payment_Typology_1Self-Pay:Age_Group.Q 1.335e+03
## Payment_Typology_1Unknown:Age_Group.Q 4.061e+03
## Payment_Typology_1Department of Corrections:Age_Group.C 1.076e+04
## Payment_Typology_1Federal/State/Local/VA:Age_Group.C 4.003e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.C 2.482e+03
## Payment_Typology_1Medicaid:Age_Group.C 8.733e+02
## Payment_Typology_1Medicare:Age_Group.C 2.651e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.C 2.306e+03
## Payment_Typology_1Private Health Insurance:Age_Group.C 1.031e+03
## Payment_Typology_1Self-Pay:Age_Group.C 1.477e+03
## Payment_Typology_1Unknown:Age_Group.C 5.374e+03
## Payment_Typology_1Department of Corrections:Age_Group^4 NA
## Payment_Typology_1Federal/State/Local/VA:Age_Group^4 3.878e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group^4 2.263e+03
## Payment_Typology_1Medicaid:Age_Group^4 7.889e+02
## Payment_Typology_1Medicare:Age_Group^4 1.464e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group^4 2.094e+03
## Payment_Typology_1Private Health Insurance:Age_Group^4 9.461e+02
## Payment_Typology_1Self-Pay:Age_Group^4 1.364e+03
## Payment_Typology_1Unknown:Age_Group^4 4.644e+03
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 7.877e-04
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 8.118e-04
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 6.905e-04
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 6.889e-04
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs 6.173e-04
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 2.789e-03
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs 7.518e-04
## t value
## (Intercept) 34.476
## Health_Service_AreaCentral NY -0.613
## Health_Service_AreaFinger Lakes 0.602
## Health_Service_AreaHudson Valley 8.181
## Health_Service_AreaLong Island 3.551
## Health_Service_AreaNew York City 7.460
## Health_Service_AreaSouthern Tier 1.039
## Health_Service_AreaWestern NY -8.241
## Length_of_Stay 10.653
## Total_Costs 60.207
## Type_of_AdmissionEmergency -15.040
## Type_of_AdmissionNewborn -8.964
## Type_of_AdmissionNot Available -2.782
## Type_of_AdmissionTrauma 5.142
## Type_of_AdmissionUrgent 1.464
## Payment_Typology_1Department of Corrections -1.519
## Payment_Typology_1Federal/State/Local/VA -1.106
## Payment_Typology_1Managed Care, Unspecified -0.194
## Payment_Typology_1Medicaid -13.930
## Payment_Typology_1Medicare -1.462
## Payment_Typology_1Miscellaneous/Other -5.353
## Payment_Typology_1Private Health Insurance -0.634
## Payment_Typology_1Self-Pay -30.699
## Payment_Typology_1Unknown -2.126
## Age_Group.L 4.610
## Age_Group.Q -3.692
## Age_Group.C 1.480
## Age_Group^4 -0.282
## APR_Severity_of_Illness_DescMajor -29.099
## APR_Severity_of_Illness_DescMinor -29.065
## APR_Severity_of_Illness_DescModerate -29.039
## APR_Risk_of_MortalityMajor -10.645
## APR_Risk_of_MortalityMinor -10.876
## APR_Risk_of_MortalityModerate -10.158
## Health_Service_AreaCentral NY:Length_of_Stay -10.579
## Health_Service_AreaFinger Lakes:Length_of_Stay -8.490
## Health_Service_AreaHudson Valley:Length_of_Stay -18.709
## Health_Service_AreaLong Island:Length_of_Stay 17.288
## Health_Service_AreaNew York City:Length_of_Stay 23.039
## Health_Service_AreaSouthern Tier:Length_of_Stay -7.830
## Health_Service_AreaWestern NY:Length_of_Stay 1.537
## Health_Service_AreaCentral NY:Total_Costs 1.345
## Health_Service_AreaFinger Lakes:Total_Costs -5.352
## Health_Service_AreaHudson Valley:Total_Costs 27.684
## Health_Service_AreaLong Island:Total_Costs 12.388
## Health_Service_AreaNew York City:Total_Costs -17.427
## Health_Service_AreaSouthern Tier:Total_Costs 5.739
## Health_Service_AreaWestern NY:Total_Costs -4.905
## Length_of_Stay:Total_Costs 6.896
## Payment_Typology_1Department of Corrections:Age_Group.L 0.192
## Payment_Typology_1Federal/State/Local/VA:Age_Group.L -2.579
## Payment_Typology_1Managed Care, Unspecified:Age_Group.L -0.457
## Payment_Typology_1Medicaid:Age_Group.L -4.926
## Payment_Typology_1Medicare:Age_Group.L -0.229
## Payment_Typology_1Miscellaneous/Other:Age_Group.L 2.835
## Payment_Typology_1Private Health Insurance:Age_Group.L -3.813
## Payment_Typology_1Self-Pay:Age_Group.L -19.798
## Payment_Typology_1Unknown:Age_Group.L -1.186
## Payment_Typology_1Department of Corrections:Age_Group.Q -0.394
## Payment_Typology_1Federal/State/Local/VA:Age_Group.Q -1.564
## Payment_Typology_1Managed Care, Unspecified:Age_Group.Q -0.371
## Payment_Typology_1Medicaid:Age_Group.Q 1.574
## Payment_Typology_1Medicare:Age_Group.Q -1.100
## Payment_Typology_1Miscellaneous/Other:Age_Group.Q -4.071
## Payment_Typology_1Private Health Insurance:Age_Group.Q -2.435
## Payment_Typology_1Self-Pay:Age_Group.Q -5.567
## Payment_Typology_1Unknown:Age_Group.Q -0.236
## Payment_Typology_1Department of Corrections:Age_Group.C -0.016
## Payment_Typology_1Federal/State/Local/VA:Age_Group.C -0.429
## Payment_Typology_1Managed Care, Unspecified:Age_Group.C 1.227
## Payment_Typology_1Medicaid:Age_Group.C -0.171
## Payment_Typology_1Medicare:Age_Group.C 2.157
## Payment_Typology_1Miscellaneous/Other:Age_Group.C 2.706
## Payment_Typology_1Private Health Insurance:Age_Group.C -1.027
## Payment_Typology_1Self-Pay:Age_Group.C -1.569
## Payment_Typology_1Unknown:Age_Group.C 0.172
## Payment_Typology_1Department of Corrections:Age_Group^4 NA
## Payment_Typology_1Federal/State/Local/VA:Age_Group^4 0.883
## Payment_Typology_1Managed Care, Unspecified:Age_Group^4 -0.457
## Payment_Typology_1Medicaid:Age_Group^4 -0.634
## Payment_Typology_1Medicare:Age_Group^4 -2.647
## Payment_Typology_1Miscellaneous/Other:Age_Group^4 -1.314
## Payment_Typology_1Private Health Insurance:Age_Group^4 -0.941
## Payment_Typology_1Self-Pay:Age_Group^4 -0.981
## Payment_Typology_1Unknown:Age_Group^4 0.049
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 0.365
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 0.051
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 7.223
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 3.185
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs -5.254
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 0.175
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs -7.242
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## Health_Service_AreaCentral NY 0.540197
## Health_Service_AreaFinger Lakes 0.546850
## Health_Service_AreaHudson Valley 2.84e-16 ***
## Health_Service_AreaLong Island 0.000384 ***
## Health_Service_AreaNew York City 8.72e-14 ***
## Health_Service_AreaSouthern Tier 0.298616
## Health_Service_AreaWestern NY < 2e-16 ***
## Length_of_Stay < 2e-16 ***
## Total_Costs < 2e-16 ***
## Type_of_AdmissionEmergency < 2e-16 ***
## Type_of_AdmissionNewborn < 2e-16 ***
## Type_of_AdmissionNot Available 0.005407 **
## Type_of_AdmissionTrauma 2.72e-07 ***
## Type_of_AdmissionUrgent 0.143125
## Payment_Typology_1Department of Corrections 0.128874
## Payment_Typology_1Federal/State/Local/VA 0.268567
## Payment_Typology_1Managed Care, Unspecified 0.845870
## Payment_Typology_1Medicaid < 2e-16 ***
## Payment_Typology_1Medicare 0.143761
## Payment_Typology_1Miscellaneous/Other 8.68e-08 ***
## Payment_Typology_1Private Health Insurance 0.525950
## Payment_Typology_1Self-Pay < 2e-16 ***
## Payment_Typology_1Unknown 0.033514 *
## Age_Group.L 4.03e-06 ***
## Age_Group.Q 0.000223 ***
## Age_Group.C 0.138942
## Age_Group^4 0.777811
## APR_Severity_of_Illness_DescMajor < 2e-16 ***
## APR_Severity_of_Illness_DescMinor < 2e-16 ***
## APR_Severity_of_Illness_DescModerate < 2e-16 ***
## APR_Risk_of_MortalityMajor < 2e-16 ***
## APR_Risk_of_MortalityMinor < 2e-16 ***
## APR_Risk_of_MortalityModerate < 2e-16 ***
## Health_Service_AreaCentral NY:Length_of_Stay < 2e-16 ***
## Health_Service_AreaFinger Lakes:Length_of_Stay < 2e-16 ***
## Health_Service_AreaHudson Valley:Length_of_Stay < 2e-16 ***
## Health_Service_AreaLong Island:Length_of_Stay < 2e-16 ***
## Health_Service_AreaNew York City:Length_of_Stay < 2e-16 ***
## Health_Service_AreaSouthern Tier:Length_of_Stay 4.92e-15 ***
## Health_Service_AreaWestern NY:Length_of_Stay 0.124355
## Health_Service_AreaCentral NY:Total_Costs 0.178644
## Health_Service_AreaFinger Lakes:Total_Costs 8.70e-08 ***
## Health_Service_AreaHudson Valley:Total_Costs < 2e-16 ***
## Health_Service_AreaLong Island:Total_Costs < 2e-16 ***
## Health_Service_AreaNew York City:Total_Costs < 2e-16 ***
## Health_Service_AreaSouthern Tier:Total_Costs 9.57e-09 ***
## Health_Service_AreaWestern NY:Total_Costs 9.34e-07 ***
## Length_of_Stay:Total_Costs 5.37e-12 ***
## Payment_Typology_1Department of Corrections:Age_Group.L 0.847594
## Payment_Typology_1Federal/State/Local/VA:Age_Group.L 0.009897 **
## Payment_Typology_1Managed Care, Unspecified:Age_Group.L 0.647754
## Payment_Typology_1Medicaid:Age_Group.L 8.40e-07 ***
## Payment_Typology_1Medicare:Age_Group.L 0.819035
## Payment_Typology_1Miscellaneous/Other:Age_Group.L 0.004579 **
## Payment_Typology_1Private Health Insurance:Age_Group.L 0.000138 ***
## Payment_Typology_1Self-Pay:Age_Group.L < 2e-16 ***
## Payment_Typology_1Unknown:Age_Group.L 0.235493
## Payment_Typology_1Department of Corrections:Age_Group.Q 0.693552
## Payment_Typology_1Federal/State/Local/VA:Age_Group.Q 0.117732
## Payment_Typology_1Managed Care, Unspecified:Age_Group.Q 0.710323
## Payment_Typology_1Medicaid:Age_Group.Q 0.115558
## Payment_Typology_1Medicare:Age_Group.Q 0.271169
## Payment_Typology_1Miscellaneous/Other:Age_Group.Q 4.68e-05 ***
## Payment_Typology_1Private Health Insurance:Age_Group.Q 0.014878 *
## Payment_Typology_1Self-Pay:Age_Group.Q 2.60e-08 ***
## Payment_Typology_1Unknown:Age_Group.Q 0.813215
## Payment_Typology_1Department of Corrections:Age_Group.C 0.987432
## Payment_Typology_1Federal/State/Local/VA:Age_Group.C 0.668021
## Payment_Typology_1Managed Care, Unspecified:Age_Group.C 0.219708
## Payment_Typology_1Medicaid:Age_Group.C 0.864262
## Payment_Typology_1Medicare:Age_Group.C 0.031005 *
## Payment_Typology_1Miscellaneous/Other:Age_Group.C 0.006801 **
## Payment_Typology_1Private Health Insurance:Age_Group.C 0.304394
## Payment_Typology_1Self-Pay:Age_Group.C 0.116587
## Payment_Typology_1Unknown:Age_Group.C 0.863347
## Payment_Typology_1Department of Corrections:Age_Group^4 NA
## Payment_Typology_1Federal/State/Local/VA:Age_Group^4 0.377434
## Payment_Typology_1Managed Care, Unspecified:Age_Group^4 0.647318
## Payment_Typology_1Medicaid:Age_Group^4 0.526006
## Payment_Typology_1Medicare:Age_Group^4 0.008110 **
## Payment_Typology_1Miscellaneous/Other:Age_Group^4 0.188843
## Payment_Typology_1Private Health Insurance:Age_Group^4 0.346569
## Payment_Typology_1Self-Pay:Age_Group^4 0.326758
## Payment_Typology_1Unknown:Age_Group^4 0.961171
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs 0.714968
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs 0.959640
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs 5.12e-13 ***
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs 0.001449 **
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs 1.49e-07 ***
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs 0.860729
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs 4.43e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 25790 on 137229 degrees of freedom
## Multiple R-squared: 0.8364, Adjusted R-squared: 0.8363
## F-statistic: 7794 on 90 and 137229 DF, p-value: < 2.2e-16
# Compute the MAD value
madA10 <- median(abs(totalCharges10$residuals))
madA10
## [1] 5887.513
Since most of the health insurance charges depends on patients' age, so we wanted to see the interaction between the Payment_Typology_1 * Age_Group. Not surprisingly we see that our Model Fit just got even more better, with the least MAD so far of about 5887.513.
# Model 11 (Best One So Far) : Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Health_Service_Area * Length_of_Stay for Model Fitting
totalCharges11 <- lm(Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area + Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train)
summary(totalCharges11)
##
## Call:
## lm(formula = Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area +
## Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc +
## APR_Risk_of_Mortality, data = ipd_train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -762318 -6706 -271 5642 1301980
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 2.436e+04 6.324e+02
## Total_Costs 1.600e+00 5.239e-03
## Length_of_Stay 1.913e+03 4.259e+01
## Health_Service_AreaCentral NY -9.413e+02 4.963e+02
## Health_Service_AreaFinger Lakes 5.613e+01 4.925e+02
## Health_Service_AreaHudson Valley 1.407e+03 4.492e+02
## Health_Service_AreaLong Island -2.676e+02 4.336e+02
## Health_Service_AreaNew York City 3.855e+03 3.735e+02
## Health_Service_AreaSouthern Tier 2.906e+03 9.001e+02
## Health_Service_AreaWestern NY -2.475e+03 4.902e+02
## Payment_Typology_1Department of Corrections -8.009e+03 2.153e+03
## Payment_Typology_1Federal/State/Local/VA -2.833e+03 1.155e+03
## Payment_Typology_1Managed Care, Unspecified -1.349e+03 8.016e+02
## Payment_Typology_1Medicaid -5.856e+03 3.072e+02
## Payment_Typology_1Medicare -2.040e+03 3.149e+02
## Payment_Typology_1Miscellaneous/Other -3.207e+03 8.238e+02
## Payment_Typology_1Private Health Insurance 3.953e+00 3.595e+02
## Payment_Typology_1Self-Pay -2.499e+04 5.547e+02
## Payment_Typology_1Unknown -5.081e+03 1.336e+03
## Age_Group.L -1.813e+03 2.664e+02
## Age_Group.Q -2.668e+03 2.179e+02
## Age_Group.C 1.518e+03 2.800e+02
## Age_Group^4 -9.657e+02 2.661e+02
## Type_of_AdmissionEmergency -5.181e+03 3.217e+02
## Type_of_AdmissionNewborn -6.427e+04 6.982e+03
## Type_of_AdmissionNot Available -7.545e+03 3.623e+03
## Type_of_AdmissionTrauma 9.844e+03 1.416e+03
## Type_of_AdmissionUrgent -4.906e+02 4.776e+02
## APR_Severity_of_Illness_DescMajor -9.846e+03 3.212e+02
## APR_Severity_of_Illness_DescMinor -1.230e+04 4.339e+02
## APR_Severity_of_Illness_DescModerate -1.117e+04 3.839e+02
## APR_Risk_of_MortalityMajor -4.128e+03 3.585e+02
## APR_Risk_of_MortalityMinor -5.005e+03 4.636e+02
## APR_Risk_of_MortalityModerate -4.302e+03 4.086e+02
## Length_of_Stay:Health_Service_AreaCentral NY -9.541e+02 6.142e+01
## Length_of_Stay:Health_Service_AreaFinger Lakes -1.519e+03 5.721e+01
## Length_of_Stay:Health_Service_AreaHudson Valley 1.580e+03 5.157e+01
## Length_of_Stay:Health_Service_AreaLong Island 3.372e+03 5.049e+01
## Length_of_Stay:Health_Service_AreaNew York City 1.794e+02 4.458e+01
## Length_of_Stay:Health_Service_AreaSouthern Tier -1.241e+03 1.194e+02
## Length_of_Stay:Health_Service_AreaWestern NY -7.862e+02 5.950e+01
## t value Pr(>|t|)
## (Intercept) 38.528 < 2e-16 ***
## Total_Costs 305.313 < 2e-16 ***
## Length_of_Stay 44.915 < 2e-16 ***
## Health_Service_AreaCentral NY -1.896 0.057907 .
## Health_Service_AreaFinger Lakes 0.114 0.909266
## Health_Service_AreaHudson Valley 3.132 0.001739 **
## Health_Service_AreaLong Island -0.617 0.537068
## Health_Service_AreaNew York City 10.321 < 2e-16 ***
## Health_Service_AreaSouthern Tier 3.229 0.001242 **
## Health_Service_AreaWestern NY -5.049 4.45e-07 ***
## Payment_Typology_1Department of Corrections -3.720 0.000199 ***
## Payment_Typology_1Federal/State/Local/VA -2.453 0.014154 *
## Payment_Typology_1Managed Care, Unspecified -1.682 0.092485 .
## Payment_Typology_1Medicaid -19.063 < 2e-16 ***
## Payment_Typology_1Medicare -6.478 9.33e-11 ***
## Payment_Typology_1Miscellaneous/Other -3.893 9.93e-05 ***
## Payment_Typology_1Private Health Insurance 0.011 0.991225
## Payment_Typology_1Self-Pay -45.054 < 2e-16 ***
## Payment_Typology_1Unknown -3.804 0.000143 ***
## Age_Group.L -6.807 9.98e-12 ***
## Age_Group.Q -12.241 < 2e-16 ***
## Age_Group.C 5.423 5.88e-08 ***
## Age_Group^4 -3.629 0.000284 ***
## Type_of_AdmissionEmergency -16.105 < 2e-16 ***
## Type_of_AdmissionNewborn -9.204 < 2e-16 ***
## Type_of_AdmissionNot Available -2.082 0.037300 *
## Type_of_AdmissionTrauma 6.951 3.65e-12 ***
## Type_of_AdmissionUrgent -1.027 0.304355
## APR_Severity_of_Illness_DescMajor -30.653 < 2e-16 ***
## APR_Severity_of_Illness_DescMinor -28.356 < 2e-16 ***
## APR_Severity_of_Illness_DescModerate -29.101 < 2e-16 ***
## APR_Risk_of_MortalityMajor -11.513 < 2e-16 ***
## APR_Risk_of_MortalityMinor -10.798 < 2e-16 ***
## APR_Risk_of_MortalityModerate -10.528 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaCentral NY -15.534 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaFinger Lakes -26.549 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaHudson Valley 30.637 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaLong Island 66.795 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaNew York City 4.025 5.69e-05 ***
## Length_of_Stay:Health_Service_AreaSouthern Tier -10.396 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaWestern NY -13.213 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 26990 on 137279 degrees of freedom
## Multiple R-squared: 0.8208, Adjusted R-squared: 0.8207
## F-statistic: 1.572e+04 on 40 and 137279 DF, p-value: < 2.2e-16
# Compute the MAD value
median(abs(totalCharges11$residuals))
## [1] 6138.078
# Model Visualization
coefplot(totalCharges11)
# Model Visualization Considering only the Numeric Predictors
coefplot(totalCharges11,predictors=c("Length_of_Stay","Total_Costs"))
In this Model we wanted to see the interaction between the Length_of_Stay * Health_Service_Area only without considering the interaction of the Total_Costs. Looks like not including Total_Costs, caused our Model to have a greater MAD than the previous Model 10. It also looks like Length_of_Stay is a significant Predictor along with the interaction terms Length_of_Stay and the Health_Service_Area, particularly if the Health_Service_Area is located in New York City, Long Island, and Hudson Valley, which makes sense since those areas are costly.
# Model 12: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Health_Service_Area * Length_of_Stay and removing the Predictor APR_Risk_of_Mortality for Model Fitting
totalCharges12 <- lm(Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area + Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc, data = ipd_train)
summary(totalCharges12)
##
## Call:
## lm(formula = Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area +
## Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc,
## data = ipd_train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -762036 -6665 -284 5623 1302180
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 2.189e+04 5.980e+02
## Total_Costs 1.603e+00 5.236e-03
## Length_of_Stay 1.921e+03 4.260e+01
## Health_Service_AreaCentral NY -9.205e+02 4.966e+02
## Health_Service_AreaFinger Lakes 1.006e+02 4.927e+02
## Health_Service_AreaHudson Valley 1.478e+03 4.493e+02
## Health_Service_AreaLong Island -2.655e+02 4.338e+02
## Health_Service_AreaNew York City 3.871e+03 3.737e+02
## Health_Service_AreaSouthern Tier 2.956e+03 9.004e+02
## Health_Service_AreaWestern NY -2.426e+03 4.904e+02
## Payment_Typology_1Department of Corrections -8.050e+03 2.154e+03
## Payment_Typology_1Federal/State/Local/VA -2.836e+03 1.155e+03
## Payment_Typology_1Managed Care, Unspecified -1.350e+03 8.019e+02
## Payment_Typology_1Medicaid -5.887e+03 3.073e+02
## Payment_Typology_1Medicare -1.978e+03 3.146e+02
## Payment_Typology_1Miscellaneous/Other -3.187e+03 8.242e+02
## Payment_Typology_1Private Health Insurance 9.194e+00 3.596e+02
## Payment_Typology_1Self-Pay -2.499e+04 5.550e+02
## Payment_Typology_1Unknown -5.054e+03 1.336e+03
## Age_Group.L -1.416e+03 2.556e+02
## Age_Group.Q -2.502e+03 2.167e+02
## Age_Group.C 1.601e+03 2.797e+02
## Age_Group^4 -9.418e+02 2.662e+02
## Type_of_AdmissionEmergency -5.091e+03 3.216e+02
## Type_of_AdmissionNewborn -6.467e+04 6.986e+03
## Type_of_AdmissionNot Available -7.530e+03 3.625e+03
## Type_of_AdmissionTrauma 9.869e+03 1.417e+03
## Type_of_AdmissionUrgent -4.568e+02 4.777e+02
## APR_Severity_of_Illness_DescMajor -1.181e+04 2.712e+02
## APR_Severity_of_Illness_DescMinor -1.489e+04 3.248e+02
## APR_Severity_of_Illness_DescModerate -1.363e+04 2.794e+02
## Length_of_Stay:Health_Service_AreaCentral NY -9.568e+02 6.145e+01
## Length_of_Stay:Health_Service_AreaFinger Lakes -1.518e+03 5.724e+01
## Length_of_Stay:Health_Service_AreaHudson Valley 1.575e+03 5.159e+01
## Length_of_Stay:Health_Service_AreaLong Island 3.375e+03 5.051e+01
## Length_of_Stay:Health_Service_AreaNew York City 1.708e+02 4.459e+01
## Length_of_Stay:Health_Service_AreaSouthern Tier -1.226e+03 1.194e+02
## Length_of_Stay:Health_Service_AreaWestern NY -7.869e+02 5.953e+01
## t value Pr(>|t|)
## (Intercept) 36.611 < 2e-16 ***
## Total_Costs 306.096 < 2e-16 ***
## Length_of_Stay 45.095 < 2e-16 ***
## Health_Service_AreaCentral NY -1.854 0.063793 .
## Health_Service_AreaFinger Lakes 0.204 0.838289
## Health_Service_AreaHudson Valley 3.290 0.001002 **
## Health_Service_AreaLong Island -0.612 0.540506
## Health_Service_AreaNew York City 10.360 < 2e-16 ***
## Health_Service_AreaSouthern Tier 3.283 0.001026 **
## Health_Service_AreaWestern NY -4.947 7.56e-07 ***
## Payment_Typology_1Department of Corrections -3.737 0.000186 ***
## Payment_Typology_1Federal/State/Local/VA -2.455 0.014080 *
## Payment_Typology_1Managed Care, Unspecified -1.684 0.092273 .
## Payment_Typology_1Medicaid -19.156 < 2e-16 ***
## Payment_Typology_1Medicare -6.287 3.24e-10 ***
## Payment_Typology_1Miscellaneous/Other -3.867 0.000110 ***
## Payment_Typology_1Private Health Insurance 0.026 0.979603
## Payment_Typology_1Self-Pay -45.020 < 2e-16 ***
## Payment_Typology_1Unknown -3.782 0.000156 ***
## Age_Group.L -5.539 3.04e-08 ***
## Age_Group.Q -11.544 < 2e-16 ***
## Age_Group.C 5.724 1.04e-08 ***
## Age_Group^4 -3.538 0.000404 ***
## Type_of_AdmissionEmergency -15.829 < 2e-16 ***
## Type_of_AdmissionNewborn -9.257 < 2e-16 ***
## Type_of_AdmissionNot Available -2.077 0.037779 *
## Type_of_AdmissionTrauma 6.965 3.30e-12 ***
## Type_of_AdmissionUrgent -0.956 0.338994
## APR_Severity_of_Illness_DescMajor -43.533 < 2e-16 ***
## APR_Severity_of_Illness_DescMinor -45.849 < 2e-16 ***
## APR_Severity_of_Illness_DescModerate -48.773 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaCentral NY -15.570 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaFinger Lakes -26.520 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaHudson Valley 30.537 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaLong Island 66.814 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaNew York City 3.829 0.000129 ***
## Length_of_Stay:Health_Service_AreaSouthern Tier -10.263 < 2e-16 ***
## Length_of_Stay:Health_Service_AreaWestern NY -13.219 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27010 on 137282 degrees of freedom
## Multiple R-squared: 0.8206, Adjusted R-squared: 0.8205
## F-statistic: 1.697e+04 on 37 and 137282 DF, p-value: < 2.2e-16
# Compute the MAD value
median(abs(totalCharges12$residuals))
## [1] 6121.064
In this Model we tried to see the Model Fit by considering the interaction between Length_of_Stay and Health_Service_Area. Since from our previous EAD we saw that Length-of_Stay and Health_Service_Area are significant for the purpose of predicting the Total_Charges of patients. We also removed the Predictor APR_Risk_of_Mortality, since Total_Charges should not be much influenced by it. And our MAD value is still lower than Model 11.
# Model 13: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Total_Costs * Length_of_Stay * Health_Service_Area and Payment_Typology_1 * Type_of_Admission and by removing the other Predictors for Model Fitting
totalCharges13 <- lm(Total_Charges ~ Total_Costs * Length_of_Stay * Health_Service_Area + Payment_Typology_1 * Type_of_Admission + Age_Group, data = ipd_train)
summary(totalCharges13)
##
## Call:
## lm(formula = Total_Charges ~ Total_Costs * Length_of_Stay * Health_Service_Area +
## Payment_Typology_1 * Type_of_Admission + Age_Group, data = ipd_train)
##
## Residuals:
## Min 1Q Median 3Q Max
## -702666 -6128 -581 5322 957492
##
## Coefficients: (10 not defined because of singularities)
## Estimate
## (Intercept) 8.577e+03
## Total_Costs 2.093e+00
## Length_of_Stay 9.643e+02
## Health_Service_AreaCentral NY -1.311e+02
## Health_Service_AreaFinger Lakes 3.931e+02
## Health_Service_AreaHudson Valley 4.459e+03
## Health_Service_AreaLong Island 1.515e+03
## Health_Service_AreaNew York City 3.331e+03
## Health_Service_AreaSouthern Tier 1.026e+03
## Health_Service_AreaWestern NY -4.124e+03
## Payment_Typology_1Department of Corrections -1.121e+04
## Payment_Typology_1Federal/State/Local/VA -9.792e+03
## Payment_Typology_1Managed Care, Unspecified -1.652e+03
## Payment_Typology_1Medicaid -1.125e+04
## Payment_Typology_1Medicare -3.583e+03
## Payment_Typology_1Miscellaneous/Other -1.746e+04
## Payment_Typology_1Private Health Insurance 7.577e+02
## Payment_Typology_1Self-Pay -1.714e+04
## Payment_Typology_1Unknown -1.093e+04
## Type_of_AdmissionEmergency -5.668e+03
## Type_of_AdmissionNewborn -1.590e+05
## Type_of_AdmissionNot Available -8.606e+03
## Type_of_AdmissionTrauma 2.184e+03
## Type_of_AdmissionUrgent 2.150e+03
## Age_Group.L 5.896e+02
## Age_Group.Q -2.400e+03
## Age_Group.C 1.395e+03
## Age_Group^4 -7.675e+02
## Total_Costs:Length_of_Stay 2.146e-03
## Total_Costs:Health_Service_AreaCentral NY 8.524e-02
## Total_Costs:Health_Service_AreaFinger Lakes -2.674e-01
## Total_Costs:Health_Service_AreaHudson Valley 1.087e+00
## Total_Costs:Health_Service_AreaLong Island 4.739e-01
## Total_Costs:Health_Service_AreaNew York City -6.782e-01
## Total_Costs:Health_Service_AreaSouthern Tier 9.762e-01
## Total_Costs:Health_Service_AreaWestern NY -2.536e-01
## Length_of_Stay:Health_Service_AreaCentral NY -1.381e+03
## Length_of_Stay:Health_Service_AreaFinger Lakes -1.062e+03
## Length_of_Stay:Health_Service_AreaHudson Valley -1.869e+03
## Length_of_Stay:Health_Service_AreaLong Island 1.707e+03
## Length_of_Stay:Health_Service_AreaNew York City 1.998e+03
## Length_of_Stay:Health_Service_AreaSouthern Tier -2.203e+03
## Length_of_Stay:Health_Service_AreaWestern NY 2.107e+02
## Payment_Typology_1Department of Corrections:Type_of_AdmissionEmergency 3.247e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionEmergency 8.510e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionEmergency 1.490e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionEmergency 6.294e+03
## Payment_Typology_1Medicare:Type_of_AdmissionEmergency 3.072e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionEmergency 1.662e+04
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionEmergency -5.024e+02
## Payment_Typology_1Self-Pay:Type_of_AdmissionEmergency -5.577e+03
## Payment_Typology_1Unknown:Type_of_AdmissionEmergency 7.059e+03
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNewborn NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNewborn 1.436e+05
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNewborn NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNewborn 1.494e+05
## Payment_Typology_1Medicare:Type_of_AdmissionNewborn 1.693e+05
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNewborn NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNewborn NA
## Payment_Typology_1Self-Pay:Type_of_AdmissionNewborn -1.849e+05
## Payment_Typology_1Unknown:Type_of_AdmissionNewborn NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNot Available NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNot Available 2.623e+04
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNot Available NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNot Available 1.819e+04
## Payment_Typology_1Medicare:Type_of_AdmissionNot Available -2.680e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNot Available NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNot Available -2.338e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionNot Available 6.194e+03
## Payment_Typology_1Unknown:Type_of_AdmissionNot Available NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionTrauma 9.545e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionTrauma 6.288e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionTrauma 9.978e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionTrauma 9.784e+03
## Payment_Typology_1Medicare:Type_of_AdmissionTrauma 4.115e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionTrauma 2.139e+04
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionTrauma -1.660e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionTrauma 1.328e+04
## Payment_Typology_1Unknown:Type_of_AdmissionTrauma NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionUrgent -2.448e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionUrgent 3.981e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionUrgent -5.857e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionUrgent 7.757e+03
## Payment_Typology_1Medicare:Type_of_AdmissionUrgent -6.763e+02
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionUrgent 9.554e+03
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionUrgent -3.756e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionUrgent -1.337e+04
## Payment_Typology_1Unknown:Type_of_AdmissionUrgent -1.063e+03
## Total_Costs:Length_of_Stay:Health_Service_AreaCentral NY 8.382e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaFinger Lakes 3.353e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaHudson Valley 5.705e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaLong Island 2.695e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaNew York City -1.997e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaSouthern Tier 2.778e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaWestern NY -4.889e-03
## Std. Error
## (Intercept) 9.216e+02
## Total_Costs 3.239e-02
## Length_of_Stay 8.012e+01
## Health_Service_AreaCentral NY 5.680e+02
## Health_Service_AreaFinger Lakes 5.797e+02
## Health_Service_AreaHudson Valley 5.272e+02
## Health_Service_AreaLong Island 5.073e+02
## Health_Service_AreaNew York City 4.362e+02
## Health_Service_AreaSouthern Tier 1.061e+03
## Health_Service_AreaWestern NY 5.639e+02
## Payment_Typology_1Department of Corrections 6.785e+03
## Payment_Typology_1Federal/State/Local/VA 4.018e+03
## Payment_Typology_1Managed Care, Unspecified 1.901e+03
## Payment_Typology_1Medicaid 1.134e+03
## Payment_Typology_1Medicare 9.319e+02
## Payment_Typology_1Miscellaneous/Other 2.319e+03
## Payment_Typology_1Private Health Insurance 1.108e+03
## Payment_Typology_1Self-Pay 3.248e+03
## Payment_Typology_1Unknown 5.754e+03
## Type_of_AdmissionEmergency 8.737e+02
## Type_of_AdmissionNewborn 1.510e+04
## Type_of_AdmissionNot Available 7.906e+03
## Type_of_AdmissionTrauma 5.502e+03
## Type_of_AdmissionUrgent 1.305e+03
## Age_Group.L 2.424e+02
## Age_Group.Q 2.095e+02
## Age_Group.C 2.702e+02
## Age_Group^4 2.571e+02
## Total_Costs:Length_of_Stay 6.117e-04
## Total_Costs:Health_Service_AreaCentral NY 5.238e-02
## Total_Costs:Health_Service_AreaFinger Lakes 5.573e-02
## Total_Costs:Health_Service_AreaHudson Valley 4.114e-02
## Total_Costs:Health_Service_AreaLong Island 4.037e-02
## Total_Costs:Health_Service_AreaNew York City 3.314e-02
## Total_Costs:Health_Service_AreaSouthern Tier 1.501e-01
## Total_Costs:Health_Service_AreaWestern NY 4.616e-02
## Length_of_Stay:Health_Service_AreaCentral NY 1.229e+02
## Length_of_Stay:Health_Service_AreaFinger Lakes 1.194e+02
## Length_of_Stay:Health_Service_AreaHudson Valley 1.010e+02
## Length_of_Stay:Health_Service_AreaLong Island 9.946e+01
## Length_of_Stay:Health_Service_AreaNew York City 8.395e+01
## Length_of_Stay:Health_Service_AreaSouthern Tier 2.756e+02
## Length_of_Stay:Health_Service_AreaWestern NY 1.114e+02
## Payment_Typology_1Department of Corrections:Type_of_AdmissionEmergency 7.144e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionEmergency 4.198e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionEmergency 2.108e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionEmergency 1.176e+03
## Payment_Typology_1Medicare:Type_of_AdmissionEmergency 9.719e+02
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionEmergency 2.491e+03
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionEmergency 1.170e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionEmergency 3.297e+03
## Payment_Typology_1Unknown:Type_of_AdmissionEmergency 5.907e+03
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNewborn NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNewborn 2.416e+04
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNewborn NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNewborn 1.848e+04
## Payment_Typology_1Medicare:Type_of_AdmissionNewborn 2.132e+04
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNewborn NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNewborn NA
## Payment_Typology_1Self-Pay:Type_of_AdmissionNewborn 3.029e+04
## Payment_Typology_1Unknown:Type_of_AdmissionNewborn NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNot Available NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNot Available 2.753e+04
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNot Available NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNot Available 1.411e+04
## Payment_Typology_1Medicare:Type_of_AdmissionNot Available 9.279e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNot Available NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNot Available 1.177e+04
## Payment_Typology_1Self-Pay:Type_of_AdmissionNot Available 2.743e+04
## Payment_Typology_1Unknown:Type_of_AdmissionNot Available NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionTrauma 1.739e+04
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionTrauma 1.650e+04
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionTrauma 1.301e+04
## Payment_Typology_1Medicaid:Type_of_AdmissionTrauma 6.257e+03
## Payment_Typology_1Medicare:Type_of_AdmissionTrauma 6.016e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionTrauma 6.456e+03
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionTrauma 6.776e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionTrauma 1.010e+04
## Payment_Typology_1Unknown:Type_of_AdmissionTrauma NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionUrgent 1.473e+04
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionUrgent 5.711e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionUrgent 3.050e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionUrgent 1.676e+03
## Payment_Typology_1Medicare:Type_of_AdmissionUrgent 1.459e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionUrgent 3.858e+03
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionUrgent 1.812e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionUrgent 4.213e+03
## Payment_Typology_1Unknown:Type_of_AdmissionUrgent 8.363e+03
## Total_Costs:Length_of_Stay:Health_Service_AreaCentral NY 7.960e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaFinger Lakes 8.207e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaHudson Valley 6.979e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaLong Island 6.964e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaNew York City 6.237e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaSouthern Tier 2.819e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaWestern NY 7.602e-04
## t value
## (Intercept) 9.307
## Total_Costs 64.613
## Length_of_Stay 12.036
## Health_Service_AreaCentral NY -0.231
## Health_Service_AreaFinger Lakes 0.678
## Health_Service_AreaHudson Valley 8.457
## Health_Service_AreaLong Island 2.986
## Health_Service_AreaNew York City 7.636
## Health_Service_AreaSouthern Tier 0.966
## Health_Service_AreaWestern NY -7.314
## Payment_Typology_1Department of Corrections -1.652
## Payment_Typology_1Federal/State/Local/VA -2.437
## Payment_Typology_1Managed Care, Unspecified -0.869
## Payment_Typology_1Medicaid -9.918
## Payment_Typology_1Medicare -3.845
## Payment_Typology_1Miscellaneous/Other -7.528
## Payment_Typology_1Private Health Insurance 0.684
## Payment_Typology_1Self-Pay -5.277
## Payment_Typology_1Unknown -1.899
## Type_of_AdmissionEmergency -6.487
## Type_of_AdmissionNewborn -10.533
## Type_of_AdmissionNot Available -1.088
## Type_of_AdmissionTrauma 0.397
## Type_of_AdmissionUrgent 1.648
## Age_Group.L 2.432
## Age_Group.Q -11.460
## Age_Group.C 5.164
## Age_Group^4 -2.985
## Total_Costs:Length_of_Stay 3.508
## Total_Costs:Health_Service_AreaCentral NY 1.627
## Total_Costs:Health_Service_AreaFinger Lakes -4.798
## Total_Costs:Health_Service_AreaHudson Valley 26.430
## Total_Costs:Health_Service_AreaLong Island 11.739
## Total_Costs:Health_Service_AreaNew York City -20.466
## Total_Costs:Health_Service_AreaSouthern Tier 6.503
## Total_Costs:Health_Service_AreaWestern NY -5.494
## Length_of_Stay:Health_Service_AreaCentral NY -11.242
## Length_of_Stay:Health_Service_AreaFinger Lakes -8.897
## Length_of_Stay:Health_Service_AreaHudson Valley -18.503
## Length_of_Stay:Health_Service_AreaLong Island 17.160
## Length_of_Stay:Health_Service_AreaNew York City 23.798
## Length_of_Stay:Health_Service_AreaSouthern Tier -7.992
## Length_of_Stay:Health_Service_AreaWestern NY 1.891
## Payment_Typology_1Department of Corrections:Type_of_AdmissionEmergency 0.454
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionEmergency 2.027
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionEmergency 0.707
## Payment_Typology_1Medicaid:Type_of_AdmissionEmergency 5.352
## Payment_Typology_1Medicare:Type_of_AdmissionEmergency 3.161
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionEmergency 6.672
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionEmergency -0.429
## Payment_Typology_1Self-Pay:Type_of_AdmissionEmergency -1.691
## Payment_Typology_1Unknown:Type_of_AdmissionEmergency 1.195
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNewborn NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNewborn 5.943
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNewborn NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNewborn 8.086
## Payment_Typology_1Medicare:Type_of_AdmissionNewborn 7.941
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNewborn NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNewborn NA
## Payment_Typology_1Self-Pay:Type_of_AdmissionNewborn -6.104
## Payment_Typology_1Unknown:Type_of_AdmissionNewborn NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNot Available NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNot Available 0.953
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNot Available NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNot Available 1.289
## Payment_Typology_1Medicare:Type_of_AdmissionNot Available -0.289
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNot Available NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNot Available -0.199
## Payment_Typology_1Self-Pay:Type_of_AdmissionNot Available 0.226
## Payment_Typology_1Unknown:Type_of_AdmissionNot Available NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionTrauma 0.549
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionTrauma 0.381
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionTrauma 0.767
## Payment_Typology_1Medicaid:Type_of_AdmissionTrauma 1.564
## Payment_Typology_1Medicare:Type_of_AdmissionTrauma 0.684
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionTrauma 3.312
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionTrauma -0.245
## Payment_Typology_1Self-Pay:Type_of_AdmissionTrauma 1.316
## Payment_Typology_1Unknown:Type_of_AdmissionTrauma NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionUrgent -0.166
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionUrgent 0.697
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionUrgent -1.921
## Payment_Typology_1Medicaid:Type_of_AdmissionUrgent 4.628
## Payment_Typology_1Medicare:Type_of_AdmissionUrgent -0.464
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionUrgent 2.476
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionUrgent -2.073
## Payment_Typology_1Self-Pay:Type_of_AdmissionUrgent -3.175
## Payment_Typology_1Unknown:Type_of_AdmissionUrgent -0.127
## Total_Costs:Length_of_Stay:Health_Service_AreaCentral NY 1.053
## Total_Costs:Length_of_Stay:Health_Service_AreaFinger Lakes 0.409
## Total_Costs:Length_of_Stay:Health_Service_AreaHudson Valley 8.175
## Total_Costs:Length_of_Stay:Health_Service_AreaLong Island 3.871
## Total_Costs:Length_of_Stay:Health_Service_AreaNew York City -3.202
## Total_Costs:Length_of_Stay:Health_Service_AreaSouthern Tier 0.099
## Total_Costs:Length_of_Stay:Health_Service_AreaWestern NY -6.431
## Pr(>|t|)
## (Intercept) < 2e-16
## Total_Costs < 2e-16
## Length_of_Stay < 2e-16
## Health_Service_AreaCentral NY 0.817444
## Health_Service_AreaFinger Lakes 0.497733
## Health_Service_AreaHudson Valley < 2e-16
## Health_Service_AreaLong Island 0.002829
## Health_Service_AreaNew York City 2.26e-14
## Health_Service_AreaSouthern Tier 0.333858
## Health_Service_AreaWestern NY 2.61e-13
## Payment_Typology_1Department of Corrections 0.098452
## Payment_Typology_1Federal/State/Local/VA 0.014817
## Payment_Typology_1Managed Care, Unspecified 0.384823
## Payment_Typology_1Medicaid < 2e-16
## Payment_Typology_1Medicare 0.000120
## Payment_Typology_1Miscellaneous/Other 5.20e-14
## Payment_Typology_1Private Health Insurance 0.493964
## Payment_Typology_1Self-Pay 1.32e-07
## Payment_Typology_1Unknown 0.057525
## Type_of_AdmissionEmergency 8.76e-11
## Type_of_AdmissionNewborn < 2e-16
## Type_of_AdmissionNot Available 0.276378
## Type_of_AdmissionTrauma 0.691469
## Type_of_AdmissionUrgent 0.099330
## Age_Group.L 0.015023
## Age_Group.Q < 2e-16
## Age_Group.C 2.42e-07
## Age_Group^4 0.002838
## Total_Costs:Length_of_Stay 0.000452
## Total_Costs:Health_Service_AreaCentral NY 0.103649
## Total_Costs:Health_Service_AreaFinger Lakes 1.61e-06
## Total_Costs:Health_Service_AreaHudson Valley < 2e-16
## Total_Costs:Health_Service_AreaLong Island < 2e-16
## Total_Costs:Health_Service_AreaNew York City < 2e-16
## Total_Costs:Health_Service_AreaSouthern Tier 7.92e-11
## Total_Costs:Health_Service_AreaWestern NY 3.93e-08
## Length_of_Stay:Health_Service_AreaCentral NY < 2e-16
## Length_of_Stay:Health_Service_AreaFinger Lakes < 2e-16
## Length_of_Stay:Health_Service_AreaHudson Valley < 2e-16
## Length_of_Stay:Health_Service_AreaLong Island < 2e-16
## Length_of_Stay:Health_Service_AreaNew York City < 2e-16
## Length_of_Stay:Health_Service_AreaSouthern Tier 1.34e-15
## Length_of_Stay:Health_Service_AreaWestern NY 0.058641
## Payment_Typology_1Department of Corrections:Type_of_AdmissionEmergency 0.649477
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionEmergency 0.042671
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionEmergency 0.479628
## Payment_Typology_1Medicaid:Type_of_AdmissionEmergency 8.70e-08
## Payment_Typology_1Medicare:Type_of_AdmissionEmergency 0.001573
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionEmergency 2.53e-11
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionEmergency 0.667730
## Payment_Typology_1Self-Pay:Type_of_AdmissionEmergency 0.090747
## Payment_Typology_1Unknown:Type_of_AdmissionEmergency 0.232133
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNewborn NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNewborn 2.81e-09
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNewborn NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNewborn 6.20e-16
## Payment_Typology_1Medicare:Type_of_AdmissionNewborn 2.02e-15
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNewborn NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNewborn NA
## Payment_Typology_1Self-Pay:Type_of_AdmissionNewborn 1.04e-09
## Payment_Typology_1Unknown:Type_of_AdmissionNewborn NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNot Available NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNot Available 0.340672
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNot Available NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNot Available 0.197345
## Payment_Typology_1Medicare:Type_of_AdmissionNot Available 0.772683
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNot Available NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNot Available 0.842571
## Payment_Typology_1Self-Pay:Type_of_AdmissionNot Available 0.821340
## Payment_Typology_1Unknown:Type_of_AdmissionNot Available NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionTrauma 0.583005
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionTrauma 0.703195
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionTrauma 0.443091
## Payment_Typology_1Medicaid:Type_of_AdmissionTrauma 0.117904
## Payment_Typology_1Medicare:Type_of_AdmissionTrauma 0.493951
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionTrauma 0.000925
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionTrauma 0.806463
## Payment_Typology_1Self-Pay:Type_of_AdmissionTrauma 0.188324
## Payment_Typology_1Unknown:Type_of_AdmissionTrauma NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionUrgent 0.868050
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionUrgent 0.485770
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionUrgent 0.054783
## Payment_Typology_1Medicaid:Type_of_AdmissionUrgent 3.70e-06
## Payment_Typology_1Medicare:Type_of_AdmissionUrgent 0.642949
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionUrgent 0.013283
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionUrgent 0.038198
## Payment_Typology_1Self-Pay:Type_of_AdmissionUrgent 0.001500
## Payment_Typology_1Unknown:Type_of_AdmissionUrgent 0.898826
## Total_Costs:Length_of_Stay:Health_Service_AreaCentral NY 0.292348
## Total_Costs:Length_of_Stay:Health_Service_AreaFinger Lakes 0.682846
## Total_Costs:Length_of_Stay:Health_Service_AreaHudson Valley 2.99e-16
## Total_Costs:Length_of_Stay:Health_Service_AreaLong Island 0.000109
## Total_Costs:Length_of_Stay:Health_Service_AreaNew York City 0.001366
## Total_Costs:Length_of_Stay:Health_Service_AreaSouthern Tier 0.921493
## Total_Costs:Length_of_Stay:Health_Service_AreaWestern NY 1.27e-10
##
## (Intercept) ***
## Total_Costs ***
## Length_of_Stay ***
## Health_Service_AreaCentral NY
## Health_Service_AreaFinger Lakes
## Health_Service_AreaHudson Valley ***
## Health_Service_AreaLong Island **
## Health_Service_AreaNew York City ***
## Health_Service_AreaSouthern Tier
## Health_Service_AreaWestern NY ***
## Payment_Typology_1Department of Corrections .
## Payment_Typology_1Federal/State/Local/VA *
## Payment_Typology_1Managed Care, Unspecified
## Payment_Typology_1Medicaid ***
## Payment_Typology_1Medicare ***
## Payment_Typology_1Miscellaneous/Other ***
## Payment_Typology_1Private Health Insurance
## Payment_Typology_1Self-Pay ***
## Payment_Typology_1Unknown .
## Type_of_AdmissionEmergency ***
## Type_of_AdmissionNewborn ***
## Type_of_AdmissionNot Available
## Type_of_AdmissionTrauma
## Type_of_AdmissionUrgent .
## Age_Group.L *
## Age_Group.Q ***
## Age_Group.C ***
## Age_Group^4 **
## Total_Costs:Length_of_Stay ***
## Total_Costs:Health_Service_AreaCentral NY
## Total_Costs:Health_Service_AreaFinger Lakes ***
## Total_Costs:Health_Service_AreaHudson Valley ***
## Total_Costs:Health_Service_AreaLong Island ***
## Total_Costs:Health_Service_AreaNew York City ***
## Total_Costs:Health_Service_AreaSouthern Tier ***
## Total_Costs:Health_Service_AreaWestern NY ***
## Length_of_Stay:Health_Service_AreaCentral NY ***
## Length_of_Stay:Health_Service_AreaFinger Lakes ***
## Length_of_Stay:Health_Service_AreaHudson Valley ***
## Length_of_Stay:Health_Service_AreaLong Island ***
## Length_of_Stay:Health_Service_AreaNew York City ***
## Length_of_Stay:Health_Service_AreaSouthern Tier ***
## Length_of_Stay:Health_Service_AreaWestern NY .
## Payment_Typology_1Department of Corrections:Type_of_AdmissionEmergency
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionEmergency *
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionEmergency
## Payment_Typology_1Medicaid:Type_of_AdmissionEmergency ***
## Payment_Typology_1Medicare:Type_of_AdmissionEmergency **
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionEmergency ***
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionEmergency
## Payment_Typology_1Self-Pay:Type_of_AdmissionEmergency .
## Payment_Typology_1Unknown:Type_of_AdmissionEmergency
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNewborn
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNewborn ***
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNewborn
## Payment_Typology_1Medicaid:Type_of_AdmissionNewborn ***
## Payment_Typology_1Medicare:Type_of_AdmissionNewborn ***
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNewborn
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNewborn
## Payment_Typology_1Self-Pay:Type_of_AdmissionNewborn ***
## Payment_Typology_1Unknown:Type_of_AdmissionNewborn
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNot Available
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNot Available
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNot Available
## Payment_Typology_1Medicaid:Type_of_AdmissionNot Available
## Payment_Typology_1Medicare:Type_of_AdmissionNot Available
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNot Available
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNot Available
## Payment_Typology_1Self-Pay:Type_of_AdmissionNot Available
## Payment_Typology_1Unknown:Type_of_AdmissionNot Available
## Payment_Typology_1Department of Corrections:Type_of_AdmissionTrauma
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionTrauma
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionTrauma
## Payment_Typology_1Medicaid:Type_of_AdmissionTrauma
## Payment_Typology_1Medicare:Type_of_AdmissionTrauma
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionTrauma ***
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionTrauma
## Payment_Typology_1Self-Pay:Type_of_AdmissionTrauma
## Payment_Typology_1Unknown:Type_of_AdmissionTrauma
## Payment_Typology_1Department of Corrections:Type_of_AdmissionUrgent
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionUrgent
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionUrgent .
## Payment_Typology_1Medicaid:Type_of_AdmissionUrgent ***
## Payment_Typology_1Medicare:Type_of_AdmissionUrgent
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionUrgent *
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionUrgent *
## Payment_Typology_1Self-Pay:Type_of_AdmissionUrgent **
## Payment_Typology_1Unknown:Type_of_AdmissionUrgent
## Total_Costs:Length_of_Stay:Health_Service_AreaCentral NY
## Total_Costs:Length_of_Stay:Health_Service_AreaFinger Lakes
## Total_Costs:Length_of_Stay:Health_Service_AreaHudson Valley ***
## Total_Costs:Length_of_Stay:Health_Service_AreaLong Island ***
## Total_Costs:Length_of_Stay:Health_Service_AreaNew York City **
## Total_Costs:Length_of_Stay:Health_Service_AreaSouthern Tier
## Total_Costs:Length_of_Stay:Health_Service_AreaWestern NY ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 26070 on 137235 degrees of freedom
## Multiple R-squared: 0.8328, Adjusted R-squared: 0.8327
## F-statistic: 8138 on 84 and 137235 DF, p-value: < 2.2e-16
# Compute the MAD value
madA13 <- median(abs(totalCharges13$residuals))
madA13
## [1] 5745.559
Apparently Model 13 is our best Model with the least of MAD of about 5745.559! We assumed that the Total_Charges are dependent on the Length_of_Stay and the Health_Service_Area as well so we wanted to see the interaction amongst these terms. The other interactive terms that we wanted to see is the type of Insurance (Payment_Typology_1) and the reason for Admission (Type_of_Admission) as we can see that often Emergency units charge more than the Normal OPD Clinics.
Identify your top 3 models in terms of lowest MAD values to use in the next part in which you'll use them to make predictions on the test dataset.
# Top 1:- Model 13: MAD: 5745.559
# Model Coefficients
totalCharges13$coefficients
## (Intercept)
## 8.576769e+03
## Total_Costs
## 2.092693e+00
## Length_of_Stay
## 9.642973e+02
## Health_Service_AreaCentral NY
## -1.311174e+02
## Health_Service_AreaFinger Lakes
## 3.930573e+02
## Health_Service_AreaHudson Valley
## 4.458551e+03
## Health_Service_AreaLong Island
## 1.514556e+03
## Health_Service_AreaNew York City
## 3.330535e+03
## Health_Service_AreaSouthern Tier
## 1.025699e+03
## Health_Service_AreaWestern NY
## -4.124424e+03
## Payment_Typology_1Department of Corrections
## -1.121143e+04
## Payment_Typology_1Federal/State/Local/VA
## -9.791823e+03
## Payment_Typology_1Managed Care, Unspecified
## -1.652410e+03
## Payment_Typology_1Medicaid
## -1.124932e+04
## Payment_Typology_1Medicare
## -3.583418e+03
## Payment_Typology_1Miscellaneous/Other
## -1.745806e+04
## Payment_Typology_1Private Health Insurance
## 7.577020e+02
## Payment_Typology_1Self-Pay
## -1.714022e+04
## Payment_Typology_1Unknown
## -1.092811e+04
## Type_of_AdmissionEmergency
## -5.667934e+03
## Type_of_AdmissionNewborn
## -1.590034e+05
## Type_of_AdmissionNot Available
## -8.606015e+03
## Type_of_AdmissionTrauma
## 2.183620e+03
## Type_of_AdmissionUrgent
## 2.150279e+03
## Age_Group.L
## 5.895875e+02
## Age_Group.Q
## -2.400410e+03
## Age_Group.C
## 1.395257e+03
## Age_Group^4
## -7.674938e+02
## Total_Costs:Length_of_Stay
## 2.145819e-03
## Total_Costs:Health_Service_AreaCentral NY
## 8.524122e-02
## Total_Costs:Health_Service_AreaFinger Lakes
## -2.673761e-01
## Total_Costs:Health_Service_AreaHudson Valley
## 1.087368e+00
## Total_Costs:Health_Service_AreaLong Island
## 4.738542e-01
## Total_Costs:Health_Service_AreaNew York City
## -6.781504e-01
## Total_Costs:Health_Service_AreaSouthern Tier
## 9.762232e-01
## Total_Costs:Health_Service_AreaWestern NY
## -2.536169e-01
## Length_of_Stay:Health_Service_AreaCentral NY
## -1.381375e+03
## Length_of_Stay:Health_Service_AreaFinger Lakes
## -1.062120e+03
## Length_of_Stay:Health_Service_AreaHudson Valley
## -1.868622e+03
## Length_of_Stay:Health_Service_AreaLong Island
## 1.706688e+03
## Length_of_Stay:Health_Service_AreaNew York City
## 1.997811e+03
## Length_of_Stay:Health_Service_AreaSouthern Tier
## -2.202720e+03
## Length_of_Stay:Health_Service_AreaWestern NY
## 2.107388e+02
## Payment_Typology_1Department of Corrections:Type_of_AdmissionEmergency
## 3.246772e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionEmergency
## 8.510050e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionEmergency
## 1.490174e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionEmergency
## 6.293562e+03
## Payment_Typology_1Medicare:Type_of_AdmissionEmergency
## 3.072078e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionEmergency
## 1.662151e+04
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionEmergency
## -5.023892e+02
## Payment_Typology_1Self-Pay:Type_of_AdmissionEmergency
## -5.576565e+03
## Payment_Typology_1Unknown:Type_of_AdmissionEmergency
## 7.058800e+03
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNewborn
## NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNewborn
## 1.435682e+05
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNewborn
## NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNewborn
## 1.494294e+05
## Payment_Typology_1Medicare:Type_of_AdmissionNewborn
## 1.693409e+05
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNewborn
## NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNewborn
## NA
## Payment_Typology_1Self-Pay:Type_of_AdmissionNewborn
## -1.848595e+05
## Payment_Typology_1Unknown:Type_of_AdmissionNewborn
## NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionNot Available
## NA
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionNot Available
## 2.623120e+04
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionNot Available
## NA
## Payment_Typology_1Medicaid:Type_of_AdmissionNot Available
## 1.818951e+04
## Payment_Typology_1Medicare:Type_of_AdmissionNot Available
## -2.680433e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionNot Available
## NA
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionNot Available
## -2.337894e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionNot Available
## 6.193710e+03
## Payment_Typology_1Unknown:Type_of_AdmissionNot Available
## NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionTrauma
## 9.544744e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionTrauma
## 6.288085e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionTrauma
## 9.978338e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionTrauma
## 9.784144e+03
## Payment_Typology_1Medicare:Type_of_AdmissionTrauma
## 4.115377e+03
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionTrauma
## 2.138502e+04
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionTrauma
## -1.660131e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionTrauma
## 1.328239e+04
## Payment_Typology_1Unknown:Type_of_AdmissionTrauma
## NA
## Payment_Typology_1Department of Corrections:Type_of_AdmissionUrgent
## -2.447756e+03
## Payment_Typology_1Federal/State/Local/VA:Type_of_AdmissionUrgent
## 3.980542e+03
## Payment_Typology_1Managed Care, Unspecified:Type_of_AdmissionUrgent
## -5.857096e+03
## Payment_Typology_1Medicaid:Type_of_AdmissionUrgent
## 7.757024e+03
## Payment_Typology_1Medicare:Type_of_AdmissionUrgent
## -6.762940e+02
## Payment_Typology_1Miscellaneous/Other:Type_of_AdmissionUrgent
## 9.553640e+03
## Payment_Typology_1Private Health Insurance:Type_of_AdmissionUrgent
## -3.755900e+03
## Payment_Typology_1Self-Pay:Type_of_AdmissionUrgent
## -1.337397e+04
## Payment_Typology_1Unknown:Type_of_AdmissionUrgent
## -1.063257e+03
## Total_Costs:Length_of_Stay:Health_Service_AreaCentral NY
## 8.381679e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaFinger Lakes
## 3.353166e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaHudson Valley
## 5.705501e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaLong Island
## 2.695495e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaNew York City
## -1.996903e-03
## Total_Costs:Length_of_Stay:Health_Service_AreaSouthern Tier
## 2.778339e-04
## Total_Costs:Length_of_Stay:Health_Service_AreaWestern NY
## -4.889192e-03
# Model Visualization (looks awful and hence commented out!)
#coefplot(totalCharges13)
# Model Visualization Considering Probable Significant Predictors
coefplot(totalCharges13,predictors=c("Length_of_Stay","Total_Costs"))
coefplot(totalCharges13,predictors=c("Health_Service_Area","Length_of_Stay"))
# Top 2:- Model 10: MAD: 5887.513
# Model Coefficients
totalCharges10$coefficients
## (Intercept)
## 2.372823e+04
## Health_Service_AreaCentral NY
## -3.443601e+02
## Health_Service_AreaFinger Lakes
## 3.454775e+02
## Health_Service_AreaHudson Valley
## 4.267496e+03
## Health_Service_AreaLong Island
## 1.782366e+03
## Health_Service_AreaNew York City
## 3.220270e+03
## Health_Service_AreaSouthern Tier
## 1.091891e+03
## Health_Service_AreaWestern NY
## -4.603270e+03
## Length_of_Stay
## 8.451918e+02
## Total_Costs
## 1.936598e+00
## Type_of_AdmissionEmergency
## -4.673686e+03
## Type_of_AdmissionNewborn
## -5.992179e+04
## Type_of_AdmissionNot Available
## -9.633709e+03
## Type_of_AdmissionTrauma
## 6.981477e+03
## Type_of_AdmissionUrgent
## 6.717110e+02
## Payment_Typology_1Department of Corrections
## -1.120162e+04
## Payment_Typology_1Federal/State/Local/VA
## -1.743581e+03
## Payment_Typology_1Managed Care, Unspecified
## -1.941048e+02
## Payment_Typology_1Medicaid
## -5.321764e+03
## Payment_Typology_1Medicare
## -2.217468e+03
## Payment_Typology_1Miscellaneous/Other
## -5.559287e+03
## Payment_Typology_1Private Health Insurance
## -2.771368e+02
## Payment_Typology_1Self-Pay
## -1.917642e+04
## Payment_Typology_1Unknown
## -4.392072e+03
## Age_Group.L
## 3.428789e+03
## Age_Group.Q
## -2.609090e+03
## Age_Group.C
## 1.124022e+03
## Age_Group^4
## -1.961672e+02
## APR_Severity_of_Illness_DescMajor
## -8.987580e+03
## APR_Severity_of_Illness_DescMinor
## -1.219592e+04
## APR_Severity_of_Illness_DescModerate
## -1.076549e+04
## APR_Risk_of_MortalityMajor
## -3.649990e+03
## APR_Risk_of_MortalityMinor
## -4.823326e+03
## APR_Risk_of_MortalityModerate
## -3.971484e+03
## Health_Service_AreaCentral NY:Length_of_Stay
## -1.285858e+03
## Health_Service_AreaFinger Lakes:Length_of_Stay
## -1.002840e+03
## Health_Service_AreaHudson Valley:Length_of_Stay
## -1.868540e+03
## Health_Service_AreaLong Island:Length_of_Stay
## 1.700341e+03
## Health_Service_AreaNew York City:Length_of_Stay
## 1.913628e+03
## Health_Service_AreaSouthern Tier:Length_of_Stay
## -2.135046e+03
## Health_Service_AreaWestern NY:Length_of_Stay
## 1.694052e+02
## Health_Service_AreaCentral NY:Total_Costs
## 6.964333e-02
## Health_Service_AreaFinger Lakes:Total_Costs
## -2.949644e-01
## Health_Service_AreaHudson Valley:Total_Costs
## 1.126495e+00
## Health_Service_AreaLong Island:Total_Costs
## 4.944057e-01
## Health_Service_AreaNew York City:Total_Costs
## -5.718243e-01
## Health_Service_AreaSouthern Tier:Total_Costs
## 8.523819e-01
## Health_Service_AreaWestern NY:Total_Costs
## -2.235343e-01
## Length_of_Stay:Total_Costs
## 4.183159e-03
## Payment_Typology_1Department of Corrections:Age_Group.L
## 4.652541e+03
## Payment_Typology_1Federal/State/Local/VA:Age_Group.L
## -7.633147e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.L
## -9.533024e+02
## Payment_Typology_1Medicaid:Age_Group.L
## -4.363783e+03
## Payment_Typology_1Medicare:Age_Group.L
## -1.057287e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.L
## 7.012401e+03
## Payment_Typology_1Private Health Insurance:Age_Group.L
## -3.740882e+03
## Payment_Typology_1Self-Pay:Age_Group.L
## -2.733185e+04
## Payment_Typology_1Unknown:Age_Group.L
## -5.058440e+03
## Payment_Typology_1Department of Corrections:Age_Group.Q
## -7.041028e+03
## Payment_Typology_1Federal/State/Local/VA:Age_Group.Q
## -4.902018e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.Q
## -7.573504e+02
## Payment_Typology_1Medicaid:Age_Group.Q
## 1.318152e+03
## Payment_Typology_1Medicare:Age_Group.Q
## -4.326379e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.Q
## -9.480195e+03
## Payment_Typology_1Private Health Insurance:Age_Group.Q
## -2.299459e+03
## Payment_Typology_1Self-Pay:Age_Group.Q
## -7.434450e+03
## Payment_Typology_1Unknown:Age_Group.Q
## -9.594561e+02
## Payment_Typology_1Department of Corrections:Age_Group.C
## -1.694247e+02
## Payment_Typology_1Federal/State/Local/VA:Age_Group.C
## -1.716580e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group.C
## 3.045859e+03
## Payment_Typology_1Medicaid:Age_Group.C
## -1.492868e+02
## Payment_Typology_1Medicare:Age_Group.C
## 5.718840e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group.C
## 6.242162e+03
## Payment_Typology_1Private Health Insurance:Age_Group.C
## -1.058980e+03
## Payment_Typology_1Self-Pay:Age_Group.C
## -2.317970e+03
## Payment_Typology_1Unknown:Age_Group.C
## 9.249766e+02
## Payment_Typology_1Department of Corrections:Age_Group^4
## NA
## Payment_Typology_1Federal/State/Local/VA:Age_Group^4
## 3.422479e+03
## Payment_Typology_1Managed Care, Unspecified:Age_Group^4
## -1.035387e+03
## Payment_Typology_1Medicaid:Age_Group^4
## -5.002612e+02
## Payment_Typology_1Medicare:Age_Group^4
## -3.874697e+03
## Payment_Typology_1Miscellaneous/Other:Age_Group^4
## -2.751554e+03
## Payment_Typology_1Private Health Insurance:Age_Group^4
## -8.905375e+02
## Payment_Typology_1Self-Pay:Age_Group^4
## -1.337342e+03
## Payment_Typology_1Unknown:Age_Group^4
## 2.260671e+02
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs
## 2.876477e-04
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs
## 4.108154e-05
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs
## 4.987675e-03
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs
## 2.193942e-03
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs
## -3.243223e-03
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs
## 4.893246e-04
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs
## -5.444673e-03
# Model Visualization
#coefplot(totalCharges10)
# Model Visualization Considering Probable Significant Predictors
coefplot(totalCharges10,predictors=c("Length_of_Stay","Total_Costs"))
coefplot(totalCharges10,predictors=c("Health_Service_Area","Length_of_Stay"))
# Top 3:- Model 9: MAD: 5932.954
# Model Coefficients
totalCharges9$coefficients
## (Intercept)
## 2.616497e+04
## Age_Group.L
## -9.561120e+02
## Age_Group.Q
## -2.532777e+03
## Age_Group.C
## 1.356510e+03
## Age_Group^4
## -7.471119e+02
## Health_Service_AreaCentral NY
## -2.992411e+02
## Health_Service_AreaFinger Lakes
## 2.949095e+02
## Health_Service_AreaHudson Valley
## 4.248331e+03
## Health_Service_AreaLong Island
## 1.843361e+03
## Health_Service_AreaNew York City
## 3.274806e+03
## Health_Service_AreaSouthern Tier
## 7.553468e+02
## Health_Service_AreaWestern NY
## -4.413032e+03
## Length_of_Stay
## 8.660125e+02
## Total_Costs
## 1.930401e+00
## Type_of_AdmissionEmergency
## -7.331880e+03
## Type_of_AdmissionNewborn
## -1.619307e+05
## Type_of_AdmissionNot Available
## -1.019526e+04
## Type_of_AdmissionTrauma
## 1.027554e+03
## Type_of_AdmissionUrgent
## 5.450392e+02
## Payment_Typology_1Department of Corrections
## -1.050152e+04
## Payment_Typology_1Federal/State/Local/VA
## -1.019967e+04
## Payment_Typology_1Managed Care, Unspecified
## -8.825442e+02
## Payment_Typology_1Medicaid
## -1.157976e+04
## Payment_Typology_1Medicare
## -3.467508e+03
## Payment_Typology_1Miscellaneous/Other
## -1.930195e+04
## Payment_Typology_1Private Health Insurance
## 5.200559e+02
## Payment_Typology_1Self-Pay
## -1.713174e+04
## Payment_Typology_1Unknown
## -1.100834e+04
## APR_Severity_of_Illness_DescMajor
## -8.987207e+03
## APR_Severity_of_Illness_DescMinor
## -1.217463e+04
## APR_Severity_of_Illness_DescModerate
## -1.080432e+04
## APR_Risk_of_MortalityMajor
## -3.685417e+03
## APR_Risk_of_MortalityMinor
## -4.779202e+03
## APR_Risk_of_MortalityModerate
## -3.996517e+03
## Health_Service_AreaCentral NY:Length_of_Stay
## -1.310989e+03
## Health_Service_AreaFinger Lakes:Length_of_Stay
## -1.021710e+03
## Health_Service_AreaHudson Valley:Length_of_Stay
## -1.862201e+03
## Health_Service_AreaLong Island:Length_of_Stay
## 1.690201e+03
## Health_Service_AreaNew York City:Length_of_Stay
## 1.913061e+03
## Health_Service_AreaSouthern Tier:Length_of_Stay
## -2.225318e+03
## Health_Service_AreaWestern NY:Length_of_Stay
## 1.523709e+02
## Health_Service_AreaCentral NY:Total_Costs
## 7.768313e-02
## Health_Service_AreaFinger Lakes:Total_Costs
## -2.897275e-01
## Health_Service_AreaHudson Valley:Total_Costs
## 1.126642e+00
## Health_Service_AreaLong Island:Total_Costs
## 4.992046e-01
## Health_Service_AreaNew York City:Total_Costs
## -5.801169e-01
## Health_Service_AreaSouthern Tier:Total_Costs
## 8.966808e-01
## Health_Service_AreaWestern NY:Total_Costs
## -2.296820e-01
## Length_of_Stay:Total_Costs
## 4.118249e-03
## Type_of_AdmissionEmergency:Payment_Typology_1Department of Corrections
## 3.160821e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Department of Corrections
## NA
## Type_of_AdmissionNot Available:Payment_Typology_1Department of Corrections
## NA
## Type_of_AdmissionTrauma:Payment_Typology_1Department of Corrections
## 1.053207e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Department of Corrections
## -4.572332e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Federal/State/Local/VA
## 8.627579e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Federal/State/Local/VA
## 1.479052e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Federal/State/Local/VA
## 2.641471e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Federal/State/Local/VA
## 7.669897e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Federal/State/Local/VA
## 3.891365e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Managed Care, Unspecified
## 8.384883e+02
## Type_of_AdmissionNewborn:Payment_Typology_1Managed Care, Unspecified
## NA
## Type_of_AdmissionNot Available:Payment_Typology_1Managed Care, Unspecified
## NA
## Type_of_AdmissionTrauma:Payment_Typology_1Managed Care, Unspecified
## 8.015303e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Managed Care, Unspecified
## -6.749362e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Medicaid
## 6.605709e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Medicaid
## 1.531691e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Medicaid
## 1.740725e+04
## Type_of_AdmissionTrauma:Payment_Typology_1Medicaid
## 9.708967e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Medicaid
## 7.468219e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Medicare
## 2.388222e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Medicare
## 1.724779e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Medicare
## -2.975551e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Medicare
## 4.013527e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Medicare
## -1.408857e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Miscellaneous/Other
## 1.886666e+04
## Type_of_AdmissionNewborn:Payment_Typology_1Miscellaneous/Other
## NA
## Type_of_AdmissionNot Available:Payment_Typology_1Miscellaneous/Other
## NA
## Type_of_AdmissionTrauma:Payment_Typology_1Miscellaneous/Other
## 2.325781e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Miscellaneous/Other
## 9.104922e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Private Health Insurance
## -2.545903e+02
## Type_of_AdmissionNewborn:Payment_Typology_1Private Health Insurance
## NA
## Type_of_AdmissionNot Available:Payment_Typology_1Private Health Insurance
## -2.343912e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Private Health Insurance
## -1.234621e+03
## Type_of_AdmissionUrgent:Payment_Typology_1Private Health Insurance
## -3.699636e+03
## Type_of_AdmissionEmergency:Payment_Typology_1Self-Pay
## -5.198245e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Self-Pay
## -1.746980e+05
## Type_of_AdmissionNot Available:Payment_Typology_1Self-Pay
## 6.638838e+03
## Type_of_AdmissionTrauma:Payment_Typology_1Self-Pay
## 1.355821e+04
## Type_of_AdmissionUrgent:Payment_Typology_1Self-Pay
## -1.322286e+04
## Type_of_AdmissionEmergency:Payment_Typology_1Unknown
## 6.827365e+03
## Type_of_AdmissionNewborn:Payment_Typology_1Unknown
## NA
## Type_of_AdmissionNot Available:Payment_Typology_1Unknown
## NA
## Type_of_AdmissionTrauma:Payment_Typology_1Unknown
## NA
## Type_of_AdmissionUrgent:Payment_Typology_1Unknown
## -7.652257e+02
## Health_Service_AreaCentral NY:Length_of_Stay:Total_Costs
## 3.651399e-04
## Health_Service_AreaFinger Lakes:Length_of_Stay:Total_Costs
## 9.107515e-05
## Health_Service_AreaHudson Valley:Length_of_Stay:Total_Costs
## 5.049093e-03
## Health_Service_AreaLong Island:Length_of_Stay:Total_Costs
## 2.216949e-03
## Health_Service_AreaNew York City:Length_of_Stay:Total_Costs
## -3.007653e-03
## Health_Service_AreaSouthern Tier:Length_of_Stay:Total_Costs
## 8.241679e-04
## Health_Service_AreaWestern NY:Length_of_Stay:Total_Costs
## -5.262707e-03
# Model Visualization
#coefplot(totalCharges9)
# Model Visualization Considering Probable Significant Predictors
coefplot(totalCharges9,predictors=c("Length_of_Stay","Total_Costs"))
coefplot(totalCharges9,predictors=c("Health_Service_Area","Length_of_Stay"))
HACKER EXTRA: Use k-crossfold validation to select your top 3 models.
# # Model 1
# totalChargesG1 <- glm(Total_Charges ~ Total_Costs + Age_Group + Gender + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Patient_Disposition + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_train, family=gaussian(link="identity"))
Let's check if this gives the same results as lm. No they don't! Therefore we need to use family=gaussian(link="identity") for building all of our rest of our Models
# identical(coef(totalCharges1), coef(totalChargesG1))
Running the cross-validation with 5 folds
# totalChargesCV1 <- cv.glm(ipd_train, totalChargesG1, K=5)
Checking the Error
# totalChargesCV1$delta
# # Model 2
# totalChargesG2 <- glm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Patient_Disposition + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_train, family=gaussian(link="identity"))
#
# # Model 3
# totalChargesG3 <- glm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 4
# totalChargesG4 <- glm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 5
# totalChargesG5 <- glm(Total_Charges ~ Total_Costs + Length_of_Stay + Health_Service_Area + Type_of_Admission + Payment_Typology_1 + Age_Group, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 6
# totalChargesG6 <- glm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 + Type_of_Admission + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 7
# totalChargesG7 <- glm(Total_Charges ~ Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 * Total_Costs + Type_of_Admission + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 8
# totalChargesG8 <- glm(Total_Charges ~ Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 * Total_Costs + Type_of_Admission * APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train, family=gaussian(link="identity"))
# # Model 9
# totalChargesG9 <- glm(Total_Charges ~ Age_Group + Health_Service_Area * Length_of_Stay * Total_Costs + Type_of_Admission * Payment_Typology_1 + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 10
# totalChargesG10 <- glm(Total_Charges ~ Health_Service_Area * Length_of_Stay * Total_Costs + Type_of_Admission + Payment_Typology_1 * Age_Group + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 11
# totalChargesG11 <- glm(Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area + Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 12
# totalChargesG12 <- glm(Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area + Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc, data = ipd_train, family=gaussian(link="identity"))
#
#
# # Model 13
# totalChargesG13 <- glm(Total_Charges ~ Total_Costs * Length_of_Stay * Health_Service_Area + Payment_Typology_1 * Type_of_Admission + Age_Group, data = ipd_train, family=gaussian(link="identity"))
# totalChargesCV2 <- cv.glm(ipd_train, totalChargesG2, K=5)
# totalChargesCV3 <- cv.glm(ipd_train, totalChargesG3, K=5)
# totalChargesCV4 <- cv.glm(ipd_train, totalChargesG4, K=5)
# totalChargesCV5 <- cv.glm(ipd_train, totalChargesG5, K=5)
# totalChargesCV6 <- cv.glm(ipd_train, totalChargesG6, K=5)
# totalChargesCV7 <- cv.glm(ipd_train, totalChargesG7, K=5)
# totalChargesCV8 <- cv.glm(ipd_train, totalChargesG8, K=5)
# totalChargesCV9 <- cv.glm(ipd_train, totalChargesG9, K=5)
# totalChargesCV10 <- cv.glm(ipd_train, totalChargesG10, K=5)
# totalChargesCV11 <- cv.glm(ipd_train, totalChargesG11, K=5)
# totalChargesCV12 <- cv.glm(ipd_train, totalChargesG12, K=5)
# totalChargesCV13 <- cv.glm(ipd_train, totalChargesG13, K=5)
# cvResults <- as.data.frame(rbind(totalChargesCV9$delta, totalChargesCV10$delta, totalChargesCV11$delta, totalChargesCV12$delta, totalChargesCV13$delta))
# names(cvResults) <- c("Error", "Adjusted Error")
# cvResults$Model <- sprintf("totalChargesG%s",9:13)
# cvResults
Since, while running the k-crossfold validation we identified that our glm and lm were not equal and hence it makes sense that this time we are getting our Top 3 Models different. The lower the error, the better the Model Fit. Hence, according to k-crossfold validation, our Top 3 Models are: ** 1. Model 10 2. Model 9 3. Model 13 **
For your top 3 models, create a scatter plot showing actual vs fitted values of Total_Charges. Remember, it's often nice to "gather up" your results into a data frame to facilitate plotting. See the notes on comparing competing regression models. Here's what one of my scatterplots looks like.
# Putting in a Dataframe to facilitate plotting
modelTests <- data.frame(New_ActualCharges=ipd_train[,"Total_Charges"],
LM13_TotalCharges=predict(totalCharges13),
LM10_TotalCharges=predict(totalCharges10),
LM9_TotalCharges=predict(totalCharges9))
# Actual vs Fitted Values Scatterplots for the Top 3 Models
ggplot(data=modelTests, aes(x=Total_Charges,y=LM13_TotalCharges)) + geom_point()
ggplot(data=modelTests, aes(x=Total_Charges,y=LM10_TotalCharges)) + geom_point()
ggplot(data=modelTests, aes(x=Total_Charges,y=LM9_TotalCharges)) + geom_point()
Create a histogram of the residuals for your top 3 models. You may have to tweak the axes scales to make a nice histogram.
# Top 1 Model: Model 13
ggplot(totalCharges13, aes(x=.resid, binwidth=30000)) + geom_histogram() + scale_x_log10()
## Warning in self$trans$transform(x): NaNs produced
## Warning: Transformation introduced infinite values in continuous x-axis
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 73264 rows containing non-finite values (stat_bin).
# Top 2 Model: Model 10
ggplot(totalCharges10, aes(x=.resid, binwidth=30000)) + geom_histogram() + scale_x_log10()
## Warning in self$trans$transform(x): NaNs produced
## Warning in self$trans$transform(x): Transformation introduced infinite
## values in continuous x-axis
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 70751 rows containing non-finite values (stat_bin).
# Top 3 Model: Model 9
ggplot(totalCharges10, aes(x=.resid, binwidth=30000)) + geom_histogram() + scale_x_log10()
## Warning in self$trans$transform(x): NaNs produced
## Warning in self$trans$transform(x): Transformation introduced infinite
## values in continuous x-axis
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 70751 rows containing non-finite values (stat_bin).
Make an appropriate plot to check for constant variance (homeskedasticity) for your top model. Don't remember what kind of plot to make? See my notes on residual analysis or any intro stats book.
From the Residual Analysis, we considered to check our homeskedasticity of Variance along two of the most significant Predictors that is the Health Service Area and also for the Length of Stay for patients for our Top Model (Model 13). Ideally we would like to see random scatter in our Residual Analysis, but for both the plot we can see that the Residuals are not scatttered randomly but accumulated over a certain point, indicating that the variance in the residuals is not constant.
# Residual Analysis by Health_Service_Area
ggplot(data=totalCharges13, aes(x=.fitted, y = .resid)) + geom_point(aes(color=Health_Service_Area)) + labs(x="Fitted Values", y="Residuals")
# Residual Analysis by Length_of_Stay
ggplot(data=totalCharges13, aes(x=.fitted, y = .resid)) + geom_point(aes(color=Length_of_Stay)) + labs(x="Fitted Values", y="Residuals")
For each of your top 3 models, make predictions for ipd_test.
# Making Prediction with Test Data and 95% Confidence Interval
totalChargesPredict1 <- predict(totalCharges13, newdata=ipd_test, se.fit=TRUE,
interval="prediction", level=0.95)
## Warning in predict.lm(totalCharges13, newdata = ipd_test, se.fit = TRUE, :
## prediction from a rank-deficient fit may be misleading
totalChargesPredict2 <- predict(totalCharges10, newdata=ipd_test, se.fit=TRUE,
interval="prediction", level=0.95)
## Warning in predict.lm(totalCharges10, newdata = ipd_test, se.fit = TRUE, :
## prediction from a rank-deficient fit may be misleading
totalChargesPredict3 <- predict(totalCharges9, newdata=ipd_test, se.fit=TRUE,
interval="prediction", level=0.95)
## Warning in predict.lm(totalCharges9, newdata = ipd_test, se.fit = TRUE, :
## prediction from a rank-deficient fit may be misleading
# # Save relevant objects
# save(ipd_train,ipd_test,totalCharges13,totalCharges10,totalCharges9,
# totalChargesPredict1,totalChargesPredict2,totalChargesPredict3,
# file="totalChargesPredict123.rdata")
Compute the MAD for each of the three models' predictions on the test data.
HINT: Obviously you can't use the residuals (or errors) directly but will have to compute them. They are simply the difference between the actual values and your predicted values.
So, for the model I mentioned earlier that had a MAD of 7270.340 for the training data, the MAD on the test data was 7335.559. Notice that MAD for test is higher than MAD for train.
# # Top 1 Predictive Model, based on Model 13 of Train Data
# totalChargesPredict13 <- lm(Total_Charges ~ Total_Costs * Length_of_Stay * Health_Service_Area + Payment_Typology_1 * Type_of_Admission + Age_Group, data = ipd_test)
#
# summary(totalChargesPredict13)
#
# # Compute the MAD value
# madP13 <- median(abs(totalChargesPredict13$residuals))
# madP13
df1 <- abs(totalChargesPredict1$fit[,1]-ipd_test["Total_Charges"])
(testMad13 <- median(as.numeric(df1$Total_Charges)))
## [1] 5752.152
# # Top 2 Predictive Model, based on Model 10 of Train Data
# totalChargesPredict10 <- lm(Total_Charges ~ Health_Service_Area * Length_of_Stay * Total_Costs + Type_of_Admission + Payment_Typology_1 * Age_Group + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_test)
#
# summary(totalChargesPredict10)
#
# # Compute the MAD value
# madP10 <- median(abs(totalChargesPredict10$residuals))
# madP10
df2 <- abs(totalChargesPredict2$fit[,1]-ipd_test["Total_Charges"])
(testMad10 <- median(as.numeric(df2$Total_Charges)))
## [1] 5856.165
# # Top 3 Predictive Model, based on Model 9 of Train Data
# totalChargesPredict9 <- lm(Total_Charges ~ Age_Group + Health_Service_Area * Length_of_Stay * Total_Costs + Type_of_Admission * Payment_Typology_1 + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_test)
#
# summary(totalChargesPredict9)
#
# # Compute the MAD value
# madP9 <- median(abs(totalChargesPredict9$residuals))
# madP9
df3 <- abs(totalChargesPredict3$fit[,1]-ipd_test["Total_Charges"])
(testMad9 <- median(as.numeric(df3$Total_Charges)))
## [1] 5888.697
QUESTION: Do you think it's typical that MAD for test would be higher than MAD for train? Why or why not?
In this case, we can clearly see that the MAD for test data is higher for the MAD value of our train data for our first top Model, Model 13. However, it might not be the case always as we can see in case of our next Models, Model 10 and Model 9 whereby MAD for train data is higher than that of the test data indicating a possibility of Model Overfitting. If there is inherent variability in the dataset as seen in our Correlation Matrix & Residual Analysis plot above then the MAD for test data will be usually higher than that of the MAD for train data.
QUESTION: Which of your top 3 models had the lowest MAD for the test data?
The Top 3 Models with the MAD for train and test data are as follows, with MAD values in ascending order: 1. Model 13, Train MAD: 5745.559, Test MAD: 5777.55 2. Model 10, Train MAD: 5887.513, Test MAD: 5856.165 3. Model 9, Train MAD: 5932.954, Test MAD: 5888.697
So, clearly our Model 13 which is our Top Model has the lowest MAD for the test data. Apart from Model 10 and Model 9, the MAD was greater for the test data for all other Models.
QUESTION: How do the MAD values for the test data compare to the MAD values for the training data?
For comapring the MAD values for the test data to the MAD values of the training data, included all the other Models except the Top 3, which are already done above.
# # Predictive Model, based on Model 1 of Train Data
# totalChargesPredict1 <- lm(Total_Charges ~ Total_Costs + Age_Group + Gender + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Patient_Disposition + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_test)
#
# summary(totalChargesPredict1)
#
# # Compute the MAD value
# median(abs(totalChargesPredict1$residuals))
# # Model 2: Build to Understand the effect of the Predictors on the Response Variable
# totalChargesPredict2 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Patient_Disposition + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_test)
#
# summary(totalChargesPredict2)
#
# # Compute the MAD value
# median(abs(totalChargesPredict2$residuals))
# # Model 3: Build to Understand the effect of the Predictors on the Response Variable
# totalChargesPredict3 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc + APR_DRG_Desc, data = ipd_test)
#
# summary(totalChargesPredict3)
#
# # Compute the MAD value
# median(abs(totalChargesPredict3$residuals))
# # Model 4: Build to Understand the effect of the Predictors on the Response Variable, by removing APR_DRG_Desc for viewing the Correlation Matrix
# totalChargesPredict4 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Race + Ethnicity + Length_of_Stay + Type_of_Admission + Payment_Typology_1 + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_test)
#
# summary(totalChargesPredict4)
#
# # Compute the MAD value
# median(abs(totalChargesPredict4$residuals))
# # Model 5: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & considering the Predictors Total_Costs, Length_of_Stay, Health_Service_Area, Type_of_Admission, Payment_Typology_1, and Age_Group by removing the other Predictors for Model Fitting
#
# totalChargesPredict5 <- lm(Total_Charges ~ Total_Costs + Length_of_Stay + Health_Service_Area + Type_of_Admission + Payment_Typology_1 + Age_Group, data = ipd_test)
#
# summary(totalChargesPredict5)
#
# # Compute the MAD value
# median(abs(totalChargesPredict5$residuals))
#
# # Model Visualization
# coefplot(totalChargesPredict5)
#
# # Model Visualization Considering Removing Some Insignificant Predictors
# coefplot(totalChargesPredict5,predictors=c("Length_of_Stay","Total_Costs", "Health_Service_Area", "Type_of_Admission", "Payment_Typology_1"))
# # Model 6: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Length_of_Stay * Payment_Typology_1 for Model Fitting
#
# totalChargesPredict6 <- lm(Total_Charges ~ Total_Costs + Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 + Type_of_Admission + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_test)
#
# summary(totalChargesPredict6)
#
# # Compute the MAD value
# median(abs(totalChargesPredict6$residuals))
# # Model 7: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Length_of_Stay * Payment_Typology_1 * Total_Costs for Model Fitting.
#
# totalChargesPredict7 <- lm(Total_Charges ~ Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 * Total_Costs + Type_of_Admission + APR_Risk_of_Mortality + APR_Severity_of_Illness_Desc, data = ipd_test)
#
# summary(totalChargesPredict7)
#
# # Compute the MAD value
# median(abs(totalChargesPredict7$residuals))
# # Model 8: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Length_of_Stay * Payment_Typology_1 * Total_Costs along with Type_of_Admission * APR_Severity_of_Illness_Desc for Model Fitting.
#
# totalChargesPredict8 <- lm(Total_Charges ~ Age_Group + Health_Service_Area + Length_of_Stay * Payment_Typology_1 * Total_Costs + Type_of_Admission * APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_test)
#
# summary(totalChargesPredict8)
#
# # Compute the MAD value
# median(abs(totalChargesPredict8$residuals))
# # Model 11 (Best One So Far) : Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Health_Service_Area * Length_of_Stay for Model Fitting
#
# totalChargesPredict11 <- lm(Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area + Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc + APR_Risk_of_Mortality, data = ipd_test)
#
# summary(totalChargesPredict11)
#
# # Compute the MAD value
# median(abs(totalChargesPredict11$residuals))
#
# # Model Visualization
# coefplot(totalChargesPredict11)
#
# # Model Visualization Considering only the Numeric Predictors
# coefplot(totalChargesPredict11,predictors=c("Length_of_Stay","Total_Costs"))
# # Model 12: Build to Understand the effect of the Predictors on the Response Variable, by removing Race, Ethnicity, & introducing the interaction terms Health_Service_Area * Length_of_Stay and removing the Predictor APR_Risk_of_Mortality for Model Fitting
#
# totalChargesPredict12 <- lm(Total_Charges ~ Total_Costs + Length_of_Stay * Health_Service_Area + Payment_Typology_1 + Age_Group + Type_of_Admission + APR_Severity_of_Illness_Desc, data = ipd_test)
#
# summary(totalChargesPredict12)
#
# # Compute the MAD value
# median(abs(totalChargesPredict12$residuals))
Across all the 13 Models, the MAD values for the test data are comparatively higher than the MAD values of the train data, except for Model 10 and Model 9 where MAD for train data is higher than that of the test data.
Finally, create some sort of plot which shows the MAD values for both train and test for your top 3 models. One plot.
# Plotting MAD values for both the train and test data Top 3 Models
trainMads = c(madA9, madA10, madA13)
testMads = c(testMad9, testMad10, testMad13)
df4 <- data.frame(trainMads, testMads)
ggplot(data = df4) + geom_point(aes(x = trainMads, y = testMads), size = 3)
Show your top performing model and discuss whether the model appears to make sense in terms of the variables included. Why did you choose the variables you did?
Apparently Model 13 is our best Model with the least MAD of about 5745.559! We assumed that the Total_Charges are dependent on the Length_of_Stay and the Health_Service_Area as well so we wanted to see the interaction amongst these terms. We decided to see the interactions amongst these terms mainly due to the fact that from our EDA over the data we saw that Total_Charges showed significant relationship with the patients' Length_of_Stay along with the Health_Service_Area where the services are being provided. The other interactive terms that we wanted to see is the type of Insurance (Payment_Typology_1) and the reason for Admission (Type_of_Admission) as we can see that often Emergency units charge more than the Normal OPD Clinics. We haven't considered race, ethnicity mainly because our Model was not showing them to be significant while we were building the Models with the train data. Additionally, we also realized that APR_DRG_Desc is a much more clinical way of naming the diseases as described under CCS_Dx_Desc. So in the initial plots we first removed CCS_Dx_Desc to see if there was any significant relationship and then we removed APR_DRG_Desc, because it wasn't showing any significant relationship either. Both of these two Predictors were insignificant probably due to the fact that we have considered to predict the Total_Charges based on patients' data related to Respiratory diseases only. And, hence the decision to remove them from our Model consideration. Initially we thought that Payment_Typology_1 could be a significant Predictor as well, but as we were building the Models, we realized that they are not significant probably due to the fact that most of the Insurance companies are more or less following the same market regulations and policy laid down by the Government, while charging for patients' respiratory diseases to ensure there is no market monopoly.
It will be interesting to compare the best models that everyone finds.
Later we'll learn more techniques that will likely allow us to beat simple linear models.